From: Jim Haungs Date: 2004-09-18T07:34:45+09:00 Subject: Re: Accessing Hash elements in sorted order? One of the nifty abstractions in Smalltalk that is missing in Ruby is the Association class. An association is simply a key/value pair, and a dictionary is simply a Set of Associations, where duplicates are not allowed because the default equality operation on Association compares two associations by their keys. Association also defines a default <= ordering method. Separating these two concepts supports cleaner sorting by key and by value, and simplifies various kinds of enumeration. Assocations are also useful by themselves for other kinds of paired objects. On Sat, 18 Sep 2004 05:08:26 +0900, Hal Fulton wrote: >Markus wrote: >> On Fri, 2004-09-17 at 12:14, Chris wrote: >> >>>>There has been some discussion going on whether Ruby's Hash should be >>>>sorted by default on this list recently. >>>> >>> >>>I would vote in favor of it. >> >> >> I'd vote against, for the following reasons. >> >> 1. Every time it comes up the thread goes quite a while before the >> advocates realize that they aren't all assuming the same sorting >> order. Some are thinking "sorted by key (obviously)" while >> others are thinking "sorted by order of insertion (obviously)" >> and still others are thinking "sorted by value" or "sorted by >> some arbitrary key so long as it's consistent," etc. > >Let's distinguis between "sorted" and "ordered." If it's ordered, you >can sort it however you like. > > >Hal > >