http://www.perlmonks.org?node_id=200368


in reply to READDIR - Sort by Time?

my @dirfiles = sort { -M $a <=> -M $b } grep !/^\.\.?$/, readdir ORDERS;

should work, I guess. Don't forget to prepend $a and $b with the directory path you opened (if you're not working in ./).

--twerq

Update: Aristotle's solution is better. :)