From: Hal Fulton Date: 2004-12-03T08:43:27+09:00 Subject: Re: ordered hash ? Robert Klemme wrote: > "itsme213" schrieb im Newsbeitrag > news:Mptrd.59198$KQ2.38410@fe2.texas.rr.com... > >>Is there a pure-ruby ordered hash? I'm looking for something that will >>preserve the order in which key/value pairs were entered. The one on RAA > > is > >>buggy http://raa.ruby-lang.org/project/orderedhash/ > > > Whenever I hear "ordered hash" then I think of a hash whose keys are > ordered according to a definable order - not necessarily insertion order. > In fact, insertion order seems to me a very special case. Is this really > widely used? > I'll reply to this, since an ordered hash is on my wish list. First of all, if it HAS an order, then it can be sorted (reordered) in any way you want. The (first) important thing to me is that it HAVE an order. Secondly, insertion order should IMO be the default -- because of hash literals, if for no other reason. If I say {this=>1, that=>2, other=>3} then that is what I expect (assuming there is any order at all). I would not want my hash literals scrambled (assuming some ordering, but one not based on insertion). But as long as a hash HAS an order, you can order it any way you like -- just as we can sort an array any way we like. And yes, I know there are fundamental differences between hashes and arrays. ;) Hal