I have entity with fields:
User
and few more. Im sending to Twig array with objec
Yes, You can add custom filter:
{% for user in users|usort %}
...
{% endfor %}
and then add Extension/new filter to Twig:
new \Twig_SimpleFilter('usort', array($this, 'usortFilter'))
public function usortFilter($item){
usort($item, function ($item1, $item2) {
if ($item1['orderNo'] == $item2['orderNo']) return 0;
return $item1['orderNo'] < $item2['orderNo'] ? -1 : 1;
});
return $item;
}