use warnings; use strict; use Benchmark qw( cmpthese ); my @alpha = ('A' .. 'Z'); for( 0 .. 4 ) { foreach my $size ( 5, 10, 20, 40, 80 ) { my @data; for( 1 .. $size ) { my $num = sprintf( "%.2f", rand( 100 ) ); my $str = $alpha[ rand( @alpha ) ] . $alpha[ rand( @alpha ) ]; push( @data, join( ' ', $num, $str ) ); } print "Array size = $size:\n"; cmpthese( -10, { pg => sub { my @new = sort {(split /\s+/, $b)[0] <=> (split /\s+/, $a)[0]} @data; }, bobf => sub { my @new = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [ $_, (split( /\s+/, $_, 2 ))[0] ] } @data; } } ); print "\n"; } }