From: Andrew Timberlake Date: 2009-06-08T17:49:26+09:00 Subject: Re: How to sort array ascending, except zero ? On Mon, Jun 8, 2009 at 10:40 AM, 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 > Maybe not the most elegant solution but it gets the job done: arr = [1,4,2,0,8,9] arr = (arr - [0]).sort << 0 Otherwise you want to override <=> on Fixnum Andrew Timberlake http://ramblingsonrails.com http://MyMvelope.com - The SIMPLE way to manage your savings