How to do sorting in ROR

hi,

is there any command for sorting the list box items in ROR. if its
please tell me

Hi, are the list box items being retrieved from the DB? If so, you
can simply use the ‘:order’ within the find method of your model. For
example,

orders = Order.find(:all, :order => [“pay_type, shipped_at DESC”],
:conditions => “id = ?”, 25 )

If not, please provide more information as to how you’re populating
the list box.

Good luck,

-Conrad

Conrad T. wrote:

Hi, are the list box items being retrieved from the DB? If so, you
can simply use the ‘:order’ within the find method of your model. For
example,

orders = Order.find(:all, :order => [“pay_type, shipped_at DESC”],
:conditions => “id = ?”, 25 )

If not, please provide more information as to how you’re populating
the list box.

Good luck,

-Conrad

You can also sort any array of object by some method or attribute.

orders.sort {|a, b| a.total <=> b.total}