On 5/5/07, David A. Black <dblack / wobblini.net> wrote:
> 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 :-)

Hi David,

unfortunately Symbols are *not* comparable :( (yet)
516/17 > irb
irb(main):001:0> :a < :b
NoMethodError: undefined method `<' for :a:Symbol
        from (irb):1

that is why I talked about a potential RCR.

Cheers
Robert


-- 
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw