Hi,
Am Donnerstag, 09. Jul 2009, 19:11:46 +0900 schrieb David A. Black:
> On Thu, 9 Jul 2009, Dipti Iyengar wrote:
>> I ve to sort risks by "High" "Medium" "Low" "Info" and "Safe"
>>
>> When I sort in the model it sorts in the alphabetical order which is not
>> what i want.
>
> LEVELS = %w{ High Medium Low Info Safe }
> sorted = risks.sort_by {|r| LEVELS.index(r.capitalize) }
Gosh, this is cool! I'm ashamed of my poor case approach.
Bertram
--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de