2017-12-15 10 views
1

ロボティクストーナメントの得点表があります。ジキルのランク順に商品を注文する必要があります

マイgoogle.yml:

teams: 
    - rank: 1 
    number: 7854 
    name: Midnight Madness 
    qp: 10 
    rp: 437 
    plays: 5 

    - rank: 2 
    number: 7641 
    name: MSET Beta Fish 
    qp: 10 
    rp: 412 
    plays: 5 

    - rank: 3 
    number: 12804 
    name: LED 
    qp: 10 
    rp: 302 
    plays: 5 

https://ibb.co/dtc776

そのためのコードは次のとおりです。私は私の.ymlファイルの順位を変更したとき、それはスタックので、それを持っている必要があります

--- 
layout: pastTournaments 
title: Google Tournament 
permalink: /tournaments/google/ 
--- 

<h5 class="column-wrapper centered">These are the rankings for the Google Qualifying tournament, which was hosted on December 2, 2017.</h5> 
<br> 
<div class="column-wrapper"> 
    <div class="grid-x"> 
     <div class="large-6 shrink cell"> 
      <table> 
       <thead> 
        <tr> 
        <th width="20" class="centered">Rank</th> 
        <th width="150" class="centered">Team Number</th> 
        <th width="150" class="centered">Team</th> 
        <th width="50" class="centered">QP</th> 
        <th width="50" class="centered">RP</th> 
        <th width="50" class="centered">Plays</th> 
        </tr> 
       </thead> 
       <tbody> 
<!--This is where the jekyll starts--> 
        {% assign order = 0 %} 
        {% for team in site.data.google.teams %} 
         {% assign order = order | plus: 1 %} 
         {% if team.rank == order %} 
          <tr> 
           <td class="centered">{{ team.rank }}</td> 
           <td class="centered">{{ team.number }}</td> 
           <td class="centered">{{ team.name }}</td> 
           <td class="centered">{{ team.qp }}</td> 
           <td class="centered">{{ team.rp }}</td> 
           <td class="centered">{{ team.plays }}</td> 
          </tr> 
         {% endif %} 
        {% endfor%} 
       </tbody> 
      </table> 
     </div> 
</div> 

、 2と1を1と入れ替えた場合、2つはちょうどこのように消えます: https://ibb.co/kq0ifR

.ymlファイルのランクを変更したときに並べ替えるようにするにはどうすればよいですか?

注:私は列が

答えて

1

を閉じていない、なぜあなたはsort液体フィルターを使用することができます他のいくつかの重要でないzurbのものを持っています。

{% assign sorted = site.data.google.teams | sort:"rank" %} 

、その後:{% for team in sorted %} ...

関連する問題