Tests
Test: by-value
Template
{%- for key, value in items | dictsort(false, 'value') -%}
{{ value }}:{{ key }}
{% endfor %}
Data
{
"items": {
"a": 5,
"b": 2,
"c": 4,
"d": 6,
"e": 3,
"f": 1
}
}
Output Django (error) v1.10.1
Invalid block tag on line 1: '-'. Did you forget to register or load this tag?
Output Jinja2 v2.8.0
1:f
2:b
3:e
4:c
5:a
6:d
Output Liquid (error) v3.0.6
Liquid syntax error: Tag '{%- for key, value in items | dictsort(false, 'value') -%}' was not properly terminated with regexp: /\%\}/
Output Nunjucks v2.5.0
1:f
2:b
3:e
4:c
5:a
6:d
Output Swig (error) v1.4.2
Invalid filter "dictsort".
Output Twig (error) v1.24.2
Unknown "dictsort" filter.
Output Twigjs (error) v0.9.5
Unable to find filter dictsort
Test: case-insensitive
Template
{%- for key, value in items | dictsort(false) -%}
{{ key }}
{% endfor %}
Data
{
"items": {
"b": 1,
"B": 2,
"c": 3,
"A": 4,
"a": 5,
"C": 6
}
}
Output Django (error) v1.10.1
Invalid block tag on line 1: '-'. Did you forget to register or load this tag?
Output Jinja2 v2.8.0
A
a
B
b
c
C
Output Liquid (error) v3.0.6
Liquid syntax error: Tag '{%- for key, value in items | dictsort(false) -%}' was not properly terminated with regexp: /\%\}/
Output Nunjucks v2.5.0
A
a
b
B
c
C
Output Swig (error) v1.4.2
Invalid filter "dictsort".
Output Twig (error) v1.24.2
Unknown "dictsort" filter.
Output Twigjs (error) v0.9.5
Unable to find filter dictsort
Test: case-sensitive
Template
{%- for key, value in items | dictsort(true) -%}
{{ key }}
{% endfor %}
Data
{
"items": {
"b": 1,
"B": 2,
"c": 3,
"A": 4,
"a": 5,
"C": 6
}
}
Output Django (error) v1.10.1
Invalid block tag on line 1: '-'. Did you forget to register or load this tag?
Output Jinja2 v2.8.0
A
B
C
a
b
c
Output Liquid (error) v3.0.6
Liquid syntax error: Tag '{%- for key, value in items | dictsort(true) -%}' was not properly terminated with regexp: /\%\}/
Output Nunjucks v2.5.0
A
B
C
a
b
c
Output Swig (error) v1.4.2
Invalid filter "dictsort".
Output Twig (error) v1.24.2
Unknown "dictsort" filter.
Output Twigjs (error) v0.9.5
Unable to find filter dictsort
Test: default
Template
{%- for key, value in items | dictsort -%}
{{ key }}
{% endfor %}
Data
{
"items": {
"E": 1,
"d": 2,
"C": 3,
"a": 4,
"f": 5,
"b": 6
}
}
Output Django (error) v1.10.1
Invalid block tag on line 1: '-'. Did you forget to register or load this tag?
Output Jinja2 v2.8.0
a
b
C
d
E
f
Output Liquid (error) v3.0.6
Liquid syntax error: Tag '{%- for key, value in items | dictsort -%}' was not properly terminated with regexp: /\%\}/
Output Nunjucks v2.5.0
a
b
C
d
E
f
Output Swig (error) v1.4.2
Invalid filter "dictsort".
Output Twig (error) v1.24.2
Unknown "dictsort" filter.
Output Twigjs (error) v0.9.5
Unable to find filter dictsort