From: dblack@... Date: 2006-12-21T00:15:10+09:00 Subject: Re: tricky sort for happy visitors of Paris Hi -- On Thu, 21 Dec 2006, Josselin wrote: > all happy visitors of Paris know about the 'arrondissement', an > administrative division of the city... 20 divisions > > selecting them from a city table I can map them as : > > ['Paris 1' , 'Paris 10' , 'Paris 11' , ..... 'Paris 19' , 'Paris 2' , > 'Paris 20' , 'Paris 3' , .... 'Paris 9' ] > > is there any way to sort this array and get : > > ['Paris 1' , 'Paris 2' , 'Paris 3' , .... 'Paris 9' , 'Paris 10' , 'Paris > 11' , ..... 'Paris 19' , 'Paris 20' ] > > which seems betetr in a list... ;-)) You could do: arronds.sort_by {|a| a[/\d+/].to_i } That will grab the digits, convert them to an integer, and sort based on that. David -- 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)