KW.pm The Schwartzian Transform #10

Subroutine

                sub by_lastname {
                  my @a = split /\s/, $a;
                  my @b = split /\s/, $b;
                  return $a[1] cmp $b[1]
                    || $a[0] cmp $b[0];
                }       
  • This can be inefficient on large amounts of data

  • Multiple splits on each @a and @b

 

<< Previous | Index | Next >> Copyright © 2003 Daniel Allen