I have entity with fields:
User
and few more. Im sending to Twig array with objec
Starting with Twig 2.12 (released on October 5, 2019) you can use the sort filter with an arrow function in the arrow argument.
For example, to order by name:
{% for user in users|sort((a, b) => a.name <=> b.name) %}
{{ user.name }} {{ user.lastname}} {{ user.age}}
{% endfor %}
Twig docs: https://twig.symfony.com/doc/2.x/filters/sort.html