my %monthindex; @monthindex{@months} = 0 .. $#months; #### my @sorted = sort { $monthindex{substr $a, 0, 3} <=> $monthindex{substr $b, 0, 3} || $a cmp $b } @files; #### my @sorted = map $_->[0], sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] } map [ $_, $monthindex{substr $_, 0, 3}], @files; #### my @months = qw(jan feb mar apr may jun jul aug sep oct nov dec); my %monthindex; @monthindex{@months} = 0 .. $#months; my @sorted = map $_->[0], sort { $a->[1] <=> $b->[1] || $a->[0] cmp $b->[0] } map [ $_, $monthindex{substr lc, 0, 3}], @files;