Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4892940

Browse files
authored
do_dictsort: update example ready to copy/paste
When iterating over a dict you usually want to pull out the keys and values.
1 parent9ec465b commit4892940

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/jinja2/filters.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,16 @@ def do_dictsort(value, case_sensitive=False, by="key", reverse=False):
268268
269269
.. sourcecode:: jinja
270270
271-
{% foritem in mydict|dictsort %}
271+
{% forkey, value in mydict|dictsort %}
272272
sort the dict by key, case insensitive
273273
274-
{% foritem in mydict|dictsort(reverse=true) %}
274+
{% forkey, value in mydict|dictsort(reverse=true) %}
275275
sort the dict by key, case insensitive, reverse order
276276
277-
{% foritem in mydict|dictsort(true) %}
277+
{% forkey, value in mydict|dictsort(true) %}
278278
sort the dict by key, case sensitive
279279
280-
{% foritem in mydict|dictsort(false, 'value') %}
280+
{% forkey, value in mydict|dictsort(false, 'value') %}
281281
sort the dict by value, case insensitive
282282
"""
283283
ifby=="key":

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp