From: Bertram Scharpf Date: 2009-06-08T19:32:00+09:00 Subject: Re: How to sort array ascending, except zero ? Hi, Am Montag, 08. Jun 2009, 17:40:06 +0900 schrieb Paganoni: > 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 don't know what you want to do further with the sorted values but maybe this is an approach to consider: s = a.map { |x| x.nonzero? } s.compact! s.sort! or s, z = a.map { |x| x.nonzero? }.partition { |x| x } s.sort! puts z.length Bertram P.S.: Still, my opinion is that there should be an equivalent String#notempty? to Numeric#nonzero? ! -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de