Skip to content

Commit

Permalink
do_dictsort: update example ready to copy/paste
Browse files Browse the repository at this point in the history
When iterating over a dict you usually want to pull out the keys and values.
  • Loading branch information
mhansen authored May 16, 2020
1 parent 9ec465b commit 4892940
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/jinja2/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,16 @@ def do_dictsort(value, case_sensitive=False, by="key", reverse=False):
.. sourcecode:: jinja
{% for item in mydict|dictsort %}
{% for key, value in mydict|dictsort %}
sort the dict by key, case insensitive
{% for item in mydict|dictsort(reverse=true) %}
{% for key, value in mydict|dictsort(reverse=true) %}
sort the dict by key, case insensitive, reverse order
{% for item in mydict|dictsort(true) %}
{% for key, value in mydict|dictsort(true) %}
sort the dict by key, case sensitive
{% for item in mydict|dictsort(false, 'value') %}
{% for key, value in mydict|dictsort(false, 'value') %}
sort the dict by value, case insensitive
"""
if by == "key":
Expand Down

0 comments on commit 4892940

Please sign in to comment.