azrael
4/4/2006 2:46:00 PM
On Tue, Apr 04, 2006 at 11:13:47PM +0900, Dave Burt wrote:
> Martin Boese wrote:
> > I am building a menu structure for rails that I'd like to store in a simple
> > Hash.
> >
> > Now I found out that ruby Hashes do not keep the order, like this program:
> > ...
> > Are there any workarounds for this? Or shall I rather write my own containers?
>
> You can use SortedHash. You can get it from the RAA. It preserves sort
> order.
I assume a SortedHash is a tree of some kind? Probably Red-Black Tree,
or similar. In which case, this is not what he wants. He wants the keys
to be read out in the order in which they were inserted, he doesn't want
*sorting* per se, at all.
As far as I can tell, what he wants is a list.
Martin