Help for this page

Select Code to Download


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