KW.pm The Schwartzian Transform #14

  1. Pre-build the split array

        @split = map { [ split ] }  @names;

2) Do the comparison

        @sort = sort { $a->[1] cmp $b->[1]
                       || $a->[0] cmp $b->[0] }  @split;
  • $a and $b contain elements of @split, which were references to arrays.

  3) Join the data together

         @names = map { join ' ', @$_ }  @sort;
  • Join synopsis:

         join EXPR,LIST
  • $_ is each of the references; @$_ turn them back into regular arrays.

 

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