From: Robert Dober Date: 2007-04-09T19:22:54+09:00 Subject: Re: On 4/9/07, John Joyce wrote: > Why does this seem to sort ascending alphabetical? > > puts ({ :shoe_size => 29.5, :name => 'Fred', :age => 10, :size => > 'L' }).to_s > > > sizeLshoe_size29.5nameFredage10 I'll handle this in two parts: First what you are doing: Actually all you are doing is puts ({ :shoe_size => 29.5, :name => 'Fred', :age => 10, :size => 'L' }) The to_s applied to the return value of puts, which is nil is the empty string which is discarded. I guess that you want to get a nice representation of the hash, try puts( { :shoe_size => 29.5, :name => 'Fred', :age => 10, :size => 'L' }.inspect ) Please note that there should not be any spaces bewteen "puts" and "(" as this is deprecated. Now what you were asking: The order of the string representation of a Hash is defined as the order of the Hash, which means it is not. It is completely up to the interpreter how to iterate over a hash, how to convert it to an array or to a string. AFAIK these operations could even be inconsistent if that suited an interpreter. Use this hash to see that it is not necessarily in alphabetic descending order {:a=>42, :b=>43, :c=>44}, but be aware that it might be if you use a different interpreter than I do irb(main):036:0> RUBY_VERSION => "1.8.5" Cheers Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw