title: How to slice a sorted list in Jinja?
body: <p>I have a list of dictionaries. I want to first sort that list, then only iterate over a subset of those items.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>{% for response in responses|sort(true, attribute='response_date')[:5] %}
      &lt;p&gt;response&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>But Jinja doesn't like this syntax, and raises the error
  <code>TemplateSyntaxError: expected token 'end of statement block', got '['
  </code></p>
  
  <p>If I don't use the <code>sort()</code> filter, the slice works. But I want to use both together.</p>