From: dc Date: 2006-10-29T20:06:07+09:00 Subject: keeping a hash' sort order? hi - sure this is a common question... i have a hash of stuff that i want to load/keep in a particular order. irb(main):005:0> hsh = { "one" => 1, "two" => 2, "three" => 3, "four"=>4, "twentythree"=>23 } gives back: => {"three"=>3, "two"=>2, "twentythree"=>23, "one"=>1, "four"=>4} ruby sorts the hash in apparent random order (by object id?) how can i keep the items in the order i want? someone said i should probly not use a hash at all? however, i do want to keep the items organized in the order like above, but access thru hashkeys. hsh.each_pair{ |tag, val| ... can i use a more complex structure and sort by some internal key? thanks! /dc ------------------------------------------- David "DC" Collier +81 (0)80 6521 9559 skype: callto://d3ntaku ------------------------------------------- Pikkle 株式会社 http://www.pikkle.com -------------------------------------------