Skip to main content

reverse

array | reverse

Reverses the order of the items in an array.

Original order:
{{ collection.products | map: 'title' | join: ', ' }}

Reverse order:
{{ collection.products | reverse | map: 'title' | join: ', ' }}

Output

Original order:
Draught of Immortality, Glacier ice, Health potion, Invisibility potion

Reverse order:
Invisibility potion, Health potion, Glacier ice, Draught of Immortality

You can't use the reverse filter on strings directly. However, you can use the split filter to create an array of characters in the string, reverse that array, and then use the join filter to combine them again.

{{ collection.title | split: '' | reverse | join: '' }}

Output

snoitop elaS
Was this page helpful?