From: khaines@... Date: 2007-03-02T06:03:55+09:00 Subject: Re: Sorting a Hash On Fri, 2 Mar 2007, Rick DeNatale wrote: > Array is usually one of the fastest classes in Ruby. Of course the > real facts come from benchmarking. True. But if trying to deal with ordering elements stored in a hash, and one deletes (for example) one of those elements, one has to then do a delete on the array. If the array isn't short, this is slow. I've benchmarked this stuff to death before. > This appears to be doing something different, it appears to be > providing some kind of a hybrid of a hash, and an array with set-like > behavior as well. > > Rather than sorting the keys, it gives a sort of the insertion order > access which Hal Fulton keeps asking for. But it also has the dequeue > methods from array which push/pop/shift/unshift single values, BUT > since in this case it uses the value for the key, it also removes any > existing element with the value before adding it back. All true. And I admit that I am guilty of deleting the early parts of this conversation before noticing it, so I was just pointing out that if one's use case includes performing operations that arrays are slow at, that my lib might be useful. It mixes in Enumerable, so it is arbitrarily sortable. Kirk Haines