Skip to main content

sort

array | sort

Sorts the items in an array in case-sensitive alphabetical, or numerical, order.

{% assign tags = collection.all_tags | sort %}

{% for tag in tags -%}
{{ tag }}
{%- endfor %}

Output

Burning
Salty
dried
extra-potent
extracts
fresh
healing
ingredients
music
plant
supplies
Anchor to Sort by an array item property

Sort by an array item property

array | sort: string

You can specify an array item property to sort the array items by. You can sort by any property of the object that you're sorting.

{% assign products = collection.products | sort: 'price' %}

{% for product in products -%}
{{ product.title }}
{%- endfor %}

Output

Charcoal
Dandelion milk
Forest mushroom
Glacier ice
Ground mandrake root
Komodo dragon scale
Love Potion
Potion beats
Potion bottle
Dried chamomile
Blue Mountain Flower
Gift Card
Health potion
Mana potion
Whole bloodroot
Crocodile tears
Invisibility potion
Viper venom
Draught of Immortality
Was this page helpful?