On Mon, Jul 2, 2012 at 2:24 PM, Jan E. <[email protected]> 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/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
