From: Nasir Khan Date: 2007-03-02T03:55:22+09:00 Subject: Re: Sorting a Hash ------=_Part_25225_28773735.1172775319577 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Trying to maintain a hash "in > order" kind of ruins some of its hashiness. > > Requiring a map to maintain its entries sorted is not that unusual. You may need this (like in my case) when you need not just the keyed access to the hash elements but also the whole map, but in some order. Java's java.util.SortedMap does just that. As Ara pointed out in one of the responses, rbtree is a Ruby implementation of it. But I wonder why RAA download is not available anymore, nor there is a gem. Does anyone know if this could be in future Ruby versions? Thanks Rick for a simple solution which externally does what I want from it, however it sorts on each access to keys and values which is not very efficient for cases when the map is not updated very frequently but is accessed a number of times. One could perhaps overload the []= method and maintain a sorted parallel array in the Hash object (this is what I did in my case). Thanks for all the responses. ------=_Part_25225_28773735.1172775319577--