> From: Peter Ertl [mailto:pertl / gmx.org] > > shorter: > > > h={:c=> 1, :b=> 2, :a => 3} > > h.keys.sort_by {|s| s.to_s}.map {|key| [key, h[key]] } Shorter, faster, and (to my mind) clearer: h.to_a.sort_by {|k,v| k.to_s } If you're not using symbols for your keys, you can just do: h.to_a.sort (I'm guessing that using OrderedHash will have the same problem of symbols not being comparable in this situation).