From: "David A. Black" Date: 2004-12-03T23:24:23+09:00 Subject: Re: ordered hash ? Hi -- On Fri, 3 Dec 2004, Robert Klemme wrote: > > "David A. Black" schrieb im Newsbeitrag > news:Pine.LNX.4.44.0412030519240.28725-100000@wobblini... > > Hi -- > > > > On Fri, 3 Dec 2004, Robert Klemme wrote: > > > > > Hm, I'd prefer the "natural" order of key elements, i.e. the order > defined > > > by <=>. > > > > The problem is, though, that keys can be anything, including things > > that don't respond to <=> or that can't be meaningfully compared with > > other keys. > > But that's okay: you'll get bitten by an exception if you insert such > keys. It will work perfectly for the most common key types (I guess these > are String and maybe Fixnum). If you want such keys then you can easily > define your own ordering with the lambda you provide. There may be a lot of hashes with such keys, but I wouldn't describe that uniformity as more "natural" to a hash than the act of key/value insertion itself. I guess I'd prefer to see hash order be a characteristic of every hash (without an exception raised), regardless of the keys, and then have things like ordering by string value, etc., be the more specialized case. David -- David A. Black dblack@wobblini.net