i want to list out sorted data in list boxes. but in i don’t how to
use sorting in ROR. so can anyone tell me. actually i want to list out
the demographic categories.
Returns a new array created by sorting _self_. Comparisons for
the
sort will be done using the +<=>+ operator or using an optional
code block. The block implements a comparison between a and b,
returning -1, 0, or +1. See also +Enumerable#sort_by+.
a = [ "d", "a", "e", "c", "b" ]
a.sort #=> ["a", "b", "c", "d", "e"]
a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
checkout the :order parameter to your finder call. Don’t sort in ruby
unless you really have to. Let the database do its job and sort for
you. It’s eagerly awaiting that opportunity to serve you.