From: Mark Probert Date: 2003-01-03T23:20:44+09:00 Subject: Re: sort the hash keys Hi. At 12:50 PM 1/3/2003 +0900, Gavin wrote: >On Friday, January 3, 2003, 2:16:29 PM, Mark wrote: > > > You can also use hash.sort directly, however, be careful. It returns > > an array of [key, value]. So to sort and iterate over the hash hash_a > > do > > > hash_a.each { |item| My mistake. That should have been hash_a.sort { |item| # item is array [key, value] Sorry about the confusion. -mark. > > key = item[0] > > value = item[1] > > # do stuff ... > > } > >Better: > > hash_a.each do |key, value| > # do stuff > end