【发布时间】:2020-08-06 07:15:12
【问题描述】:
在我的代码中,我试图读取大约 100 个 yml 文件并创建一个 html 表。我面临的问题是我无法根据两列进行排序。列名称是供应商和名称。 我需要先对供应商进行排序,然后再命名。
它只对供应商列排序,忽略下一列名。所有列名都是正确的。
这是代码。
{% assign devices = "" | split: " " %}
{% for device in site.data.devices %}
{% assign devices = devices | push: device[1] %}
{% endfor %}
{% assign sorted = devices | sort_natural: 'name' | sort_natural: 'vendor' %}
{% assign lastVendor = "" %}
{% assign nbDevices = 0 %}
{%- for device in sorted %}
{%- assign nbDevices = nbDevices | plus:'1' %}
{%- assign lastVendor = device.vendor %}`
Here i start creating the table which gets filled with values from the yml files.
创建时的表仅按一列排序。供应商或名称。
按照here 的建议尝试了group_by,但表格中没有显示任何值,不知道为什么。
试过sort和sort_natural两者效果是一样的。
关于我在这里做错了什么的任何建议。
【问题讨论】:
标签: sorting markdown jekyll liquid