Twig
The flexible, fast, and securetemplate engine for PHP
sort
Found a typo or an error? Want to improve this document? Edit it.
Need support or have a technical question? Ask support on Stack Overflow.
The sort filter sorts an array:
1 2 3
{% for user in users|sort %} ... {% endfor %}
Note
Internally, Twig uses the PHP asort function to maintain index association. It supports Traversable objects by transforming those to arrays.