Gene Tani wrote:
> Steve Litt wrote:
>
>>On Thursday 08 December 2005 12:37 pm, robertj wrote:
>>
>>>hi,
>>>
>>>is there anywhere a class that does soemthing
>>>akin to java.util.SortedMap? that is sorting
>>>and iterating over the hash in the order of its
>>>keys.
>>
>>When I tried it, it seemed that Ruby automatically sorted the keys. I'm not
>>sure if this is what you want, but see this:
>>
>>http://www.troubleshooters.com/codec...al.htm#_Hashes
>>
>
>
> Not sure what "it" is, but Hash#sort will convert the hash to a list of
> lists, sorted by their keys
True, but unless you need the values stored in order internally, just do this:
hash.sort.each{ |e| puts "#{e[0]} => #{e[1]}" }
Regards,
Dan