in reply to Sorting by values doesn't work

To add to what blokhead said, you need to make sure your sort routine is using the global (package) $a and $b instead of the lexical (my) $a and $b. You can do this several ways: