in reply to Scoping issue when sorting with subroutines

Yes, you can do that; however, you should have a darn good reason for doing so. Why? Because your code will be calling a sub for each and every comparison, which is rather expensive and will slow down your program.
use warnings; use strict; my %numbers = qw(one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight + 8); sort_em(\%numbers); sub sort_em { our %nos = %{$_[0]}; print "UP:\n"; print join "\n", sort { up(\%nos) } keys %nos; print "\n\nDOWN:\n"; print join "\n", sort { down(\%nos) } keys %nos; } sub up { $_[0]->{$a} <=> $_[0]->{$b} } sub down { $_[0]->{$b} <=> $_[0]->{$a} }

--perlpelxer