ravenflux/sort-functions

Twig extension that implements sorting functions in Twig template

1.0.0 2019-01-20 20:37 UTC

README

Latest Stable Version Latest Unstable Version License Total Downloads

ravenflux.jpg

Twig extension that implements sorting functions in Twig template.

Installation

The recommended way to install is via Composer:

composer require ravenflux/sort-functions

For Symfony usage, import ravenflux/sort-function services.yaml file:

# config/services.yaml
imports:
    - { resource: '../vendor/ravenflux/sort-functions/src/Resources/config/services.yaml' }

Usage

{% for user in users|usort('name') %}
    {{ user.name }}
{% endfor %}
{% for user in users|usort('name', 'DESC') %}
    {{ user.name }}
{% endfor %}