title: Sorted navigation menu with Jekyll and Liquid
body: <p>I'm constructing a static site (no blog) with Jekyll/Liquid. I want it to have an auto-generated navigation menu that lists all existing pages and highlight the current page. The items should be added to the menu in a particular order. Therefore, I define a <code>weight</code> property in the pages' YAML:</p>
  
  <pre><code>---
  layout : default
  title  : Some title
  weight : 5
  ---
  </code></pre>
  
  <p>The navigation menu is constructed as follows:</p>
  
  <pre><code>&lt;ul&gt;
    {% for p in site.pages | sort:weight %}
      &lt;li&gt;
        &lt;a {% if p.url == page.url %}class="active"{% endif %} href="{{ p.url }}"&gt;
          {{ p.title }}
        &lt;/a&gt;
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>This creates links to all existing pages, but they're unsorted, the <code>sort</code> filter seems to be ignored. Obviously, I'm doing something wrong, but I can't figure out what.</p>