Sort filter not working

David Glick's Avatar

David Glick

20 Apr, 2011 05:33 PM via web

The sort filter appears to be broken. The following template code:

{{ site.navigation | sort: title }}

causes the following output:

Liquid error: undefined method `<=>' for #

  1. 2 Posted by John Nunemaker on 20 Apr, 2011 06:07 PM

    John Nunemaker's Avatar

    Hmm... I just did this and had no issues. Maybe put quotes around title and see if that helps.

    {{ site.navigation | sort:'title' | assign_to: 'sorted' }}
    {% for item in sorted %}
      {{ item | link_to_item }}
    {% endfor %}​
    
  2. 3 Posted by David Glick on 20 Apr, 2011 06:10 PM

    David Glick's Avatar

    Yep, that did the trick - both in the example above and the non-trivial case I was using it for. Thanks! Might want to update the docs.

  3. Jonathan Hoyt closed this discussion on 23 Apr, 2011 08:03 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM