What is the best way to sort an array of Active Record objects by by a field?
This array is a field of an object, link_pages, and I want it sorted by the field "sequence"
<% @menu_bar.link_pages.each do |lp| %>
<li id="page_<%= lp.id%>" class="ui-state-default">
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<font size=5><%= lp.name %></font> |
<%= link_to "remove",
:controller => "admin/menu_bars",
:action => :remove_page_from_menu,
:page => lp.id,
:id => @menu_bar.id %>
</li>
<% end %>
Maybe there is a way to do @menu_bar.link_pages.sort_by_sequence.each do, which would be slick, but I just don't know.