Bootstrap FreeKB - Jinja - Sort a List
Jinja - Sort a List

Updated:   |  Jinja articles

sort is a Jinja filter that can be used to:

Take for example the following.

{% set integers=[3,20,1] %}

<br /><br />

Original List: 
{{ integers }}

<br /><br />

Sorted List: 
{{ integers | sort }}

<br /><br />

Sorted List in Reverse order: 
{{ integers | sort(reverse=true) }}

 

Something like this should be returned.

Original List: [3, 20, 1]

Sorted List: [1, 3, 20]

Sorted List in Reverse order: [20, 3, 1]

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter cc03fe in the box below so that we can be sure you are a human.