I have entity with fields:
User
and few more. Im sending to Twig array with objec
With new version twig you can sort by colonne
{% set fruits = [
{ name: 'Apples', quantity: 5 },
{ name: 'Oranges', quantity: 2 },
{ name: 'Grapes', quantity: 4 },] %}
{% for fruit in fruits|sort((a, b) => a.quantity <=> b.quantity)|column('name') %}
{{ fruit }}
{% endfor %}
https://twig.symfony.com/doc/2.x/filters/sort.html