my $first = 'run_this_first'; # or whatever @filenames = sort { ($b eq $first) cmp ($a eq $first) || -M $b <=> -M $a } @filenames;