From 75a729781d065b35ad82c2e3048f616ab723054f Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sat, 10 Aug 2019 16:25:22 +0200 Subject: [PATCH] 194_top_x_of_user example: Fix sort order --- docs/codesnippets/194_top_x_of_user.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/codesnippets/194_top_x_of_user.py b/docs/codesnippets/194_top_x_of_user.py index 7a7f4c9..5778f56 100644 --- a/docs/codesnippets/194_top_x_of_user.py +++ b/docs/codesnippets/194_top_x_of_user.py @@ -9,7 +9,9 @@ X_percentage = 10 # percentage of posts that should be downloaded L = Instaloader() profile = Profile.from_username(L.context, PROFILE) -posts_sorted_by_likes = sorted(profile.get_posts(), key = lambda p: p.likes + p.comments) +posts_sorted_by_likes = sorted(profile.get_posts(), + key=lambda p: p.likes + p.comments, + reverse=True) for post in islice(posts_sorted_by_likes, ceil(profile.mediacount * X_percentage / 100)): L.download_post(post, PROFILE)