From: botp Date: 2008-10-31T13:01:04+09:00 Subject: Re: how to sort this array On Fri, Oct 31, 2008 at 5:14 AM, Li Chen wrote: > expected results: > [ "c:/ruby/self/2004/1.txt", > "c:/ruby/self/2004/2.txt", > "c:/ruby/self/2004/3.txt", > "c:/ruby/self/2004/10.txt", > "c:/ruby/self/2004/20.txt", >] apology in advance for dupl email. i sent an email an hrs back but it seems it got blackholed :) anyway, if you want basename numeric sorting, then just do eg, files.sort_by{|f| File.basename(f).to_i}