reverse

反转数组中项目的顺序。reverse 不能反转字符串。

输入

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

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

输出



plums, peaches, oranges, apples

尽管 reverse 不能直接用于字符串,但你可以将字符串拆分为数组,反转数组,并通过链接过滤器重新连接它。

输入

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

输出

.moT rojaM ot lortnoc dnuorG