rsort Twig Filter

The rsort filter sorts an array in reverse order.

You would typically save the sorted array back to the original variable or to a new variable.

This filter is unique to Aptuitiv. It is not part of the core Twig functionality.
{% set array = array|rsort %}

You can use this filter within a for loop.

{% for item in items|rsort %}
...
{% endfor %}

You can also use this filter in combination with the join filter to sort and output the array values in one step.

{{ [5,8,2,3]|rsort|join(', ') }}

That would output: 8, 5, 3, 2
This documentation is only for Aptuitiv CMS. Learn more.
Get Started With Aptuitiv