From: Robert Klemme Date: 2011-11-03T06:46:52+09:00 Subject: Re: Sort order dilemma On Wed, Nov 2, 2011 at 12:28 PM, Sam Rose wrote: > On Nov 1, 2011, at 10:28 PM, Jan wrote: > >> array.sort_by {|s| [s.size, s]} > > That's an incredibly elegant solution, thanks for sharing! :) In case you find the temporary structure created for sorting inelegant you can do this: irb(main):006:0* a = %w{A AA AB AF B C} => ["A", "AA", "AB", "AF", "B", "C"] irb(main):007:0> a.sort {|x,y| (x.length <=> y.length).nonzero? or x <=> y} => ["A", "B", "C", "AA", "AB", "AF"] Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/