我是Liquid的新手,如果这很明显,请原谅我。
我有一些数据的标题以A1,B10,C64等为前缀,在我想要排序的真实文本之前,例如“A1 Something”“B10 Nothing”“A23 Another”。
如果我使用
{% assign itemssorted = product.ds_related_products | sort: 'title' %}
{% for item in itemssorted %}
然后我得到根据前缀排序的项目,而我想要的是在前缀后按文本排序的项目。
是否有像
这样的东西{% assign itemssorted = product.ds_related_products | sort: 'title' | split: ' ' .... %}
我可以用来实现这个吗?
答案 0 :(得分:0)
尝试更改要排序的变量的排序:价格:
{% assign products = collection.products | sort: 'price' %}
{% for product in products %}
<h4>{{ product.title }}</h4>
{% endfor %}
<!-- products = "a", "b", "A", "B" -->
{% assign products = collection.products | sort: 'title' %}
{% for product in products %}
{{ product.title }}
{% endfor %}