reverse

Reverses the order of the items in an array. reverse cannot reverse a string.

Input

{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}

{{ my_array | reverse | join: ", " }}

Output

plums, peaches, oranges, apples

Although reverse cannot be used directly on a string, you can split a string into an array, reverse the array, and rejoin it by chaining together filters:

Input

{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}

Output

.moT rojaM ot lortnoc dnuorG

© 2005, 2006 Tobias Luetke
Licensed under the MIT License.
https://shopify.github.io/liquid/filters/reverse/