use Benchmark qw(cmpthese); my @numbers; for (1..100) { my $random = int( rand(9000)) + 5; push @numbers, $random; } cmpthese(-5, { "Schwartz-1" => sub { my @sorted = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { my $num = $_; $num =~ /\d+/; [ $_, $num ]; } @numbers }, "Schwartz-0" => sub { my @sorted = map { $_->[1] } sort { $b->[0] <=> $a->[0] } map { my $num = $_; $num =~ /\d+/; [ $num, $_ ]; } @numbers }, });