Help for this page
# 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; }
# we pass the sub the actual values to compare foreach my $id ( ... # return the *opposite* answer return ($direction eq 'DESC') ? -($result) : $result; }