Hi --

On 5/5/07, Robert Dober <robert.dober / gmail.com> wrote:
> On 5/5/07, dblack / wobblini.net <dblack / wobblini.net> wrote:
> > 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
> sorted_keys = hash.keys.sort_by{|k| k.to_s }
> as pointed out already.

I can't seem to find the first two or three messages in this thread
anywhere (including Google groups), so I may have missed something.
Are only talking about strings and symbols as keys?  If so I won't
bother pointing out that to_s won't work with integers :-)


David

-- 
Upcoming Rails training by Ruby Power and Light:
  Four-day Intro to Intermediate
  May 8-11, 2007
  Edison, NJ
  http://www.rubypal.com/events/05082007