http://qs321.pair.com?node_id=660372


in reply to Re^2: Using $a and $b for sort
in thread Using $a and $b for sort

if there is some strange reason you cannot lexify your other usages of $a and $b, then you can consider using a named ($$)-prototyped sort subroutine, and perl will pass the sort variables in @_ instead of package variables.
sub mysort ($$) { $_[0]->{key} <=> $_[1]->{key} } my @sorted = sort mysort @unsorted;