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/.