From: Harry Kakueki Date: 2009-06-08T20:07:46+09:00 Subject: Re: How to sort array ascending, except zero ? On Mon, Jun 8, 2009 at 7:59 PM, Harry Kakueki wrote: > On Mon, Jun 8, 2009 at 5:40 PM, Paganoni wrote: >> Hello, I need to sort >> [1,4,2,0,8,9] to [1,2,4,8,9,0] >> >> A simple ascending sort but with the zero values to the end >> >> I really don't see how to do >> >> Thanks for your help >> >> > > > > tmp = arr.partition{|x| x != 0 } > (tmp[0].sort + tmp[1]) > > Harry > -- > A Look into Japanese Ruby List in English > http://www.kakueki.com/ruby/list.html > Oops! tmp = arr.partition{|x| x != 0 } p (tmp[0].sort + tmp[1]) The second line should be like this, of course. Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html