From: Siep Korteling Date: 2008-01-29T07:26:30+09:00 Subject: Re: Hash Sorting Nico Ritsche wrote: > result should look like this: > > pi_array_sorted = > { 'general_event_types', [GeneralEventType1, GeneralEventType2, ..], > 'prices', [Price1, Price2, ..], > 'specific_event_types', [SpecificEventType1, SpecificEventType2, ..], > 'general_event_types', [Teacher1, Teacher2, ..] } > > So the keys should be in alphabetical order, but they arent, (...) Well, they are, if the last 'general_event_types' is substituted with 'teachers', what it probably should be. I guess you want the values sorted. I don't now Rails, but hey, it's ruby. You can probably do @parent_items['teachers'] = Teacher.find(:all).sort in your second and following lines. Or: pi_array_sorted = @parent_items.sort.by{|key, value|value.sort!;key} to have your subarrays sorted and the keys as well in one go. Regards, Siep -- Posted via http://www.ruby-forum.com/.