sortΒΆ

The sort filter sorts an array:

{% 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.