This should do it.
<% for recipe in @recipes.sort{|a,b| a.title <=> b.title } %>
Dave wrote:
This should do it.
<% for recipe in @recipes.sort{|a,b| a.title <=> b.title } %>
Dave wrote:
Jon Garvin wrote in post #148415:
This should do it.
<% for recipe in @recipes.sort{|a,b| a.title <=> b.title } %>
Jon Garvin .. you are awesome... I struggled the entire day yesterday
figuring out how to sort a dynamic list based on categories
alphabetically while working on creating a styleguide based on ruby. I
have no experience working on ruby. When i found this link via google i
finally got my Eureka Moment. Thanks once again for providing the code.
The magic code that helped me was .sort{|a,b| a<==>b}
just to provide the entire code in context i used is a below
<% for c in @categories.sort{|a,b| a <=> b} %>
<li><a href="<%= c[0] %>.html"><%= c[0] %></a></li>
<% end %>
i am wondering if i can use the same sorting filter in Jekyll...will
give a try.
thanks once again though