Skip to content

Commit

Permalink
Reverse sorting keys (h/t @felixfontein)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska committed Dec 27, 2016
1 parent e1c5a87 commit 1be9098
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nikola/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,10 @@ def sort_posts(posts, *keys, **kwargs):
reverse = kwargs['reverse']
else:
reverse = False
for key in keys:
# we reverse the keys to get the usual ordering method: the first key
# provided is the most important sorting predicate (first by 'title', then
# by 'date' in the first example)
for key in reversed(keys):
try:
# an attribute (or method) of the Post object
a = getattr(posts[0], key)
Expand Down

0 comments on commit 1be9098

Please sign in to comment.