Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

RE: Dynamic sort algorithm selection

by btrott (Parson)
on Nov 15, 2000 at 05:46 UTC ( [id://41696] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        #!/usr/bin/perl -w
        use strict;
    ...
    
        sub num { $a <=> $b }
        sub alpha { $a cmp $b }
    
  2. or download this
        % foo.pl num
        1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    
        % foo.pl alpha
        1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 5 6 7 8 9
    
  3. or download this
        SUBNAME may be a scalar variable name
        (unsubscripted), in which case the value provides
    ...
        to use.  In place of a SUBNAME, you can provide a
        BLOCK as an anonymous, in-line sort
        subroutine.