Category Sorting

You also have the capability of sorting categories with our extended_sort Twig filter.

Usage looks like this:

{% for category in tree.items|extended_sort('name', true) %}      
{% endfor %}

Where extended_sort is the Twig filter, which expects the following two parameters:

  1. The filed that you want to sort on, valid sortable fields are id, name, description, short_description, title, url_name, meta_description, meta_keywords, sort_order, api_code, is_visible, shop_category_id, created_by, updated_by, created_at, updated_at
  2. true sorts in ascending order, and false sorts in descending order

See the Display Category List article for a full example of how to show categories on any page in your store.