my @sorted = map $_->[0], sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] } map [ $_, $monthindex{substr $_, 0, 3}], @files;