Hi --

On Sat, 5 May 2007, Nicholas Clare wrote:

> On 5/5/07, Haoqi Haoqi <axgle / 126.com> wrote:
>> 
>> 
>> > Hashes are unordered.  If you need an ordered collection, you'll need
>> > to use an array.
>> 
>> 
>> Hashes are unordered. that is how sadly for me,really!
>> 
>> --
>> Posted via http://www.ruby-forum.com/.
>> 
>> 
>
> Hi, I missed some of this thread, I only just joined the list. Although it's
> less than optimal, can you not just sort the keys when you need them.
> Something like:
>
> require 'enumerator'
> sorted_keys = hash.enum_for(:each_key).to_a.sort
>
> Again, there might very well be a better way to do even that, I'm new to
> ruby.


   sorted_keys = hash.keys.sort

:-)


David

-- 
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)