From: Rodrigo Bermejo Date: 2008-03-12T23:43:34+09:00 Subject: Re: sort array by some text a = ['one.jpg', 'two.txt', 'three.pdf','a.txt', 'a.az' , 'a.z'] a_new=a.sort_by do |x| if x =~ /\.txt$/ 0 else 1 end end p a_new --> ["a.txt", "two.txt", "one.jpg", "three.pdf", "a.az", "a.z"] the sort_by block can be improved surely. -- Posted via http://www.ruby-forum.com/.