From: ara.t.howard@... Date: 2005-12-09T12:44:55+09:00 Subject: Re: ordered/sorted hash On Fri, 9 Dec 2005, robertj wrote: > 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. > > i had a look into facets dictionary but that does > only preserve the ordering of insertion which > is not what i want. > > any other suggestions? > > ciao robertj harp:~ > cat a.rb require "alib" include ALib oh = OrderedHash::new oh["first"] = 42 oh["second"] = "forty-two" puts "---" oh.each{|k,v| puts "#{ k } : #{ v }"} harp:~ > ruby a.rb --- first : 42 second : forty-two -a -- =============================================================================== | ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================