New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a sort_posts function #2608
Conversation
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
From |
That’s a sane assumption to make, I added a little |
How about being able to sort some keys reversed, and some not, by prepending |
Looks like a good solution to me. It would certainly handle what I'd like to do (and more). |
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@felixfontein done — prepend with |
# An attribute (or method) of the Post object | ||
a = getattr(posts[0], key) | ||
if callable(a): | ||
keyfunc = operator.methodcaller(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually work when key[0] == '-'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. Fixed.
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is #2602 — it adds a
sort_posts
function (available as Jinja filter in global context), which allows general-purpose timeline sorting. Example usage:cc @liffiton — does this match your needs?