sort_by_key

The sort_by_key filter sorts a multi-dimensional array by a specific value in a child array. The value is specified by the array key. The sorting is case sensitive.

By default the values are sorted in ascending order. You can pass a second parameter to sort in descending order.

This filter is unique to Aptuitiv. It is not part of the core Twig functionality.
{% set myArray = myArray|sort_by_key('age') %}
{% set myArray = myArray|sort_by_key('age', 'desc') %}
This documentation is only for Aptuitiv CMS. Learn more.
Get Started With Aptuitiv