in reply to Sorting by values doesn't work
This is why variable names of $a and $b are highly discouraged -- even when they are lexical, they can still indirectly interfere with sorting. Even when you split out the sorting subroutine, the variable names $a and/or $b are still bound to lexicals, not the global $a and $b (Perl just doesn't complain in this case). Thus the sort comparison returns the same thing every time, and your list still doesn't get sorted.Can't use "my %s" in sort comparison (F) The global variables $a and $b are reserved for sort co +mpar- isons. You mentioned $a or $b in the same line as the <=> +or cmp operator, and the variable had earlier been declared as a l +exical variable. Either qualify the sort variable with the packag +e name, or rename the lexical variable.
blokhead
|
|---|