Next Tricks of the Wizards 125

Schwartzian Transform

         @sorted_names = 
           map { $_->[0] }
           sort { $b->[1] <=> $a->[1] } 
           map { [ $_, -M $_ ] } 
           readdir D;
        User   System Total
        5.11 + 6.83 = 11.94             Naive sort
        7.37 + 0.82 =  8.19             Schwartzian transform

Premature optimization is the root of all evil.



Next Copyright © 2003 M. J. Dominus