Next Trivial Utilities 68

sortby comparator

        sub comparator {
          my @F = @field{$a, $b};
          my @re_count;
          for my $i (0 .. 1) {
            for ($F[$i]) {
              $re_count[$i]++ while s/^re:\s*//i;
              tr/A-Za-z/a-za-z/;
              tr/a-z//cd;
            }
          }
          $REVERSE * (lc $F[0] cmp lc $F[1]
                      || $re_count[0] <=> $re_count[1]
                      || $field{$a} cmp $field{$b}
                      );  
        }


Next Menu Copyright © 2012 M. J. Dominus