From: Robert Klemme Date: 2012-07-02T21:40:23+09:00 Subject: Re: how to sort this nested hash On Mon, Jul 2, 2012 at 2:24 PM, Jan E. wrote: > Like Jesus already said, you cannot sort a Hash. But of course you can > build a new Hash based on the sorted key. A Hash actually *is* ordered > by the order of which you inserted the values (I think this was > introduced in Ruby 1.9). Yes. I would rely on that feature for debug printing purposes only because the order is not fixed. If you build an ordered structure (Array) and then copy that into a Hash I think you are doing too much work because to process items in order you can already traverse the Array. > Apart from that I agree with Jesus that the structure is much too > complex. It's almost unreadable, a pain to process and very error-prone > (you rely on a certain structure which isn't enforced at all). You > should definitely switch to an object structure with *meaningful* > entities. Agree as well. Classes Struct and OpenStruct go a long way in making this much more readable. Also the usage of more telling names than "hn2" will greatly help. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/