use Benchmark (); sub argless { $hash{$a } cmp $hash{$b } } sub proto($$) { $hash{$_[0]} cmp $hash{$_[1]} } sub args { $hash{$_[0]} cmp $hash{$_[1]} } our %hash = map { (''.rand()) => $_ } qw( Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. ); Benchmark::cmpthese(0, { inline => sub { my @sorted = sort { $hash{$a} cmp $hash{$b} } keys %hash; }, argless => sub { my @sorted = sort argless keys %hash; }, proto => sub { my @sorted = sort proto keys %hash; }, args => sub { my @sorted = sort { args($a, $b) } keys %hash; }, }); __END__ Rate args proto argless inline args 2832/s -- -33% -42% -43% proto 4258/s 50% -- -13% -14% argless 4871/s 72% 14% -- -2% inline 4973/s 76% 17% 2% --