in reply to Sort by -M

You'll need to perform the stat calls before the sorting.

@a = map $_->[0], sort { $b->[1] <=> $a->[1] } grep defined($_->[1]), map [ $_, -M $_ ], @a;

You might even get a speed boost from the reduced number of stat calls!

[Oops, this is basically identical to tybalt89's post, but it hadn't been posted yet when I started composing this post.]