ara.t.howard | 15 May 18:33

Re: Access Hash in the same order that was created


On May 15, 2008, at 10:22 AM, Mario Ruiz wrote:

> I need to access to a Hash in the same order that It was created:
>
> mh=Hash.new()
> mh["one"]="1"
> mh["two"]="2"
> mh["three"]="3"
> mh["four"]="4"
>
> mh.each {|val|
>  puts val[0]
> }
>
> In this example I get:
> three
> two
> one
> four
>
> and I would like to get:
> one
> two
> three
> four
>
>
> is that possible?
>
> Thanks

gem install orderedhash

mh = OrderedHash.new
...
...

etc.

a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama


Gmane