From: Chris Date: 2004-09-18T03:24:45+09:00 Subject: Accessing Hash elements in sorted order? Problem: I wanted to access the elements of a Hash (specifically from CGI#params) in sorted order. My resolution: Hash#sort returns an array which can be accessed via Array#each, but each item is another array. So the return of CGI.param.sort is: [[key1,value1],[key2,value2],[key3,value3],...,[keyn,valuen]] So I wrote (essentially -- the meat): cgi = CGI.new cgi.params.sort.each { |pair| puts "#{pair[0]}=#{pair[1]}" } Is this *really* the best way to access the elements of Hash in sorted order? I suppose, if at base, this is the way to do it, I could extend Hash to abstract this... -ceo