From: Florian Frank Date: 2009-02-03T18:27:20+09:00 Subject: [ruby-core:21798] Re: [Feature #1084](Closed) request for: Array#sort_by! Rados��aw Bu��at wrote: > On the one hand it would be nice to have these methods, on the other > hand it would mean that Hash isn't anymore just simple, plain Hash > (because the can be sorted and who knows what else will in the > future). My pragmatic approach tells me that it's not as bad idea to > have it. My thinking was this: We are already paying the price in memory (2 pointers) for every hash entry and I feel we don't get enough in return for this payment. If a fast way to sort the insertion ordered hashes would be available this could be something like a poor man's sorted set or map. > Without it if someone want to change order of keys he can do > this by: > h = {"b" => "bar", "a" => "foo"} > h = Hash[*h.sort.flatten] > p h Yeah, this is possible of course, but one has to create a lot of temporary arrays for the transformation. This isn't something I would like to do that often for big hashes. -- Florian Frank