From: Chris Date: 2004-09-18T04:14:46+09:00 Subject: Re: Accessing Hash elements in sorted order? Florian Gross wrote: > Chris wrote: > >> cgi = CGI.new >> cgi.params.sort.each { |pair| puts "#{pair[0]}=#{pair[1]}" } > > > One small suggestion: > > cgi.params.sort.each do |(key, value)| > puts "#{key}=#{value}" > end > This is *exactly* what I was looking for. Figured there had to be a way to access the key/value directly as above. >> 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... > > > There has been some discussion going on whether Ruby's Hash should be > sorted by default on this list recently. > I would vote in favor of it. -ceo