for ( @old_array ) { $times{ $_ } = -M $_; } my @sorted = sort { $times{$a} <=> $times{$b} } @old_array;