Help for this page

Select Code to Download


  1. or download this
    # note passing your sub $a and $b
    foreach my $id (sort { mysort($direction,$a,$b) } keys %hash) {
    ...
        # return the *opposite* answer
        return ($direction eq 'DESC') ? -($result) : $result;
    }
    
  2. or download this
    # we pass the sub the actual values to compare
    foreach my $id (
    ...
        # return the *opposite* answer
        return ($direction eq 'DESC') ? -($result) : $result;
    }