参考这个问题:Jekyll/Liquid Templating: How to group blog posts by year?
我已经实现了Christian Specht的答案,在我的案例中,我从_data
文件夹中存储的csv文件中返回了一个目标记分员列表,它运行良好。
但是,我如何按最高最低顺序返回这些?
此时,射手将按照他们在csv文件中出现的顺序返回。
我的代码:
<h2>Top goal scorers</h2>
<table>
{% assign goalscorers = site.data.members | sort: 'sortby' %}
{% for goalscorer in goalscorers %}
{% if goalscorer.goals > "0" %}<tr><td>
{{ goalscorer.surname }} </td><td>{{ goalscorer.goals }}</td></tr>
{% endif %}
{% endfor %}
</table>
生成的html:
<h2>Top goal scorers</h2>
<table>
<tr><td>Moore </td><td>2</td></tr>
<tr><td>Cromwell </td><td>1</td></tr>
<tr><td>Gould </td><td>3</td></tr>
<tr><td>Dowsett </td><td>6</td></tr>
<tr><td>Whalley </td><td>2</td></tr>
<tr><td>Tindall </td><td>1</td></tr>
<tr><td>Jones </td><td>1</td></tr>
</table>
答案 0 :(得分:0)
好的,我已经完成了,我需要将分配行更改为:
{% assign goalscorers = site.data.members | sort: 'goals' | reverse %}