sub mysort (&@) { my $coderef = shift; while (@_ > 1) { $a = shift; $b = $_[0]; my $c = $coderef->(); print " $c"; # do sorting } print "\n"; } mysort { $a <=> $b } qw(1 3 2);