Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
    print "numeric sort: @x\n";
    
  2. or download this
    @x = qw( 5xxx  2xxx 300x  10xx  );
    @x = sort {$a =~/^d+/ <=> $b =~/^d+/} @x; # WRONG
    print "regex sort: @x\n";
    
  3. or download this
    @x = qw( 5xxx  2xxx 300x  10xx  );
    @x = sort {my ($y) = $a =~/^(\d+)/; 
               my ($z) = $b =~/^(\d+)/; 
               $y <=> $z} @x;
    print "regex sort: @x\n";
    
  4. or download this
     _  _ _  _  
    (_|| | |(_|><
     _|