From: Josselin Date: 2006-12-19T07:00:08+09:00 Subject: Re: sorting an array w multiple values On 2006-12-18 17:29:29 +0100, dblack@wobblini.net said: > ---2049402039-1722804141-1166459366=:5255 > Content-Type: MULTIPART/MIXED; > BOUNDARY="-2049402039-1722804141-1166459366=:5255" > > This message is in MIME format. The first part should be readable text, > while the remaining parts are likely unreadable without MIME-aware tools. > > ---2049402039-1722804141-1166459366=:5255 > Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed > Content-Transfer-Encoding: QUOTED-PRINTABLE > > Hi -- > > On Tue, 19 Dec 2006, Josselin wrote: > >> I understand how to sort an array with a single value but how can I sort = > an=20 >> array w multiple values : [ integer_value1, float_value2] >> >> an_array =3D [=A0[123, 42.50], [ 245, 25.45], [389, 32.69] ] >> >> wich should give (sorting on the 2nd value) >> >> sorted_array =3D> [[ 245, 25.45], =A0[389, 32.69], [123, 42.50] ] > > sorted_array =3D an_array.sort_by {|e| e[1] } > > > David > > --=20 > Q. What's a good holiday present for the serious Rails developer? > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > aka The Ruby book for Rails developers! > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > A. Ruby Power and Light, LLC (http://www.rubypal.com) > ---2049402039-1722804141-1166459366=:5255-- > ---2049402039-1722804141-1166459366=:5255-- thanks a lot , got it... written in my secret notebook.... ;-)))