From: Benjamin Fleischer Date: 2011-06-22T01:05:30+09:00 Subject: Re: How to order a hash based on its keys? though true a hash doesn't maintain order, you can sort the keys and use the result to do something.... (though you couldn't return an ordered hash) hashes_arent_ordered = { 2=>"2", 3=>"3", 1=>"1" } hashes_arent_ordered.keys.sort.each {|key| puts "key #{key}, value #{hashes_arent_ordered[key]}"} -Benjamin, Chicago