title: Sort dict in jinja2 loop
body: <p>I'm still learning jinja2 and flask and I'm having a difficulty using dictsort in jinja2.</p>
  
  <p>So I'm passing this dict into a jinja2 template:</p>
  
  <pre><code>{'PEDD United': {'id': 37828, 'rank': 12, 'totalpts': 307},'Fc Mbonabushia': {'id': 205633, 'rank': 6, 'totalpts': 356},'FC Slurp': {'id': 933573, 'rank': 11, 'totalpts': 312},'KFC_Overijse': {'id': 38861, 'rank': 5, 'totalpts': 362},'Fc Paris': {'id': 1538051, 'rank': 2, 'totalpts': 396}}
  </code></pre>
  
  <p>What I want is create a table that is sorted by the value of the key 'totalpts'. I tried all sort of things and it just doesn't take totalpts into account when "sorting".</p>
  
  <p>Here's one of my code:</p>
  
  <pre><code>        &lt;table class="table table-bordered"&gt;
          {% for team in league %}
              &lt;tr&gt;
                  &lt;td&gt;{{team}}&lt;/td&gt;
                  {% for data in league[team]|dictsort(league[team]['totalpts']) %}
                  &lt;td&gt;{{ league[team]['totalpts'] }}&lt;/td&gt;
                  {% endfor %}
              &lt;/tr&gt;
          {% endfor %}
      &lt;/table&gt;
  </code></pre>
  
  <p>by it doesn't sort anything in this case... Just print the value in the table without any order...</p>
  
  <p>Anyone can help me out?</p>
  
  <p>thanks</p>