We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Before:
dictsort(value, case_sensitive=False, by='key')
After:
dictsort(value, case_sensitive=False, by='key', reverse=False):
Why not Jinja2 dictsort method support reverse keyword? Some guy gave the code: http://www.ifnamemain.com/posts/2014/Jul/04/jinja_pelican_dict_sort/
The text was updated successfully, but these errors were encountered:
I think you could use the reverse filter for that.
Sorry, something went wrong.
from jinja2 import Template d = {"a":2, "d":1, "c":4, "b":3} print Template("{{ d|dictsort }}").render(d=d) print Template("{{ d|dictsort(false, by='value') }}").render(d=d) s = """ {% for i in d|dictsort(false, by='value')|reverse %} {{ i }} {% endfor %} """ print Template(s).render(d=d) #output: [('a', 2), ('b', 3), ('c', 4), ('d', 1)] [('d', 1), ('a', 2), ('b', 3), ('c', 4)] ('c', 4) ('b', 3) ('a', 2) ('d', 1)
@Naddiseo Thank you! It works.
No branches or pull requests
Before:
After:
Why not Jinja2 dictsort method support reverse keyword?
Some guy gave the code: http://www.ifnamemain.com/posts/2014/Jul/04/jinja_pelican_dict_sort/
The text was updated successfully, but these errors were encountered: