Help for this page

Select Code to Download


  1. or download this
    sub sortmaker {
      my $order = shift;
      my $sub = $order ? sub { $a <=> $b } : sub {$b <=> $a};
      return $sub;
    }
    
  2. or download this
    sub sortmaker {
      my $order = shift;
      my $clause = $order ? '$a <=> $b' : '$b <=> $a';
      my $sub= eval "sub { $clause}";  # create the coderef
      return $sub;                                # explicitely return it
    }