sort_natural
对数组进行排序,并且大小写无关。
输入
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
{{ my_array | sort_natural | join: ", " }}
输出
giraffe, octopus, Sally Snake, zebra
该过滤器有一个可选参数指定了数组项目的哪个属性用于排序。
{% assign products_by_company = collection.products | sort_natural: "company" %}
{% for product in products_by_company %}
<h4>{{ product.title }}</h4>
{% endfor %}