use warnings; use strict; use Benchmark 'cmpthese'; use constant DO_CHECK => 0; use if DO_CHECK, 'Data::Compare', qw/Compare/; my @input = (-50..50); my @output = (0..50,-50..-1); use List::Util 'shuffle'; srand 123; @input = shuffle @input; # NB. NB. NB. NB. cmpthese(-2, { packz => sub { my @list = @input; @list = unpack 'i*', pack 'I*', sort { $a <=> $b } unpack 'I*', pack 'i*', @list; Compare(\@list,\@output) or die "@list" if DO_CHECK; }, Eily => sub { # https://www.perlmonks.org/?node_id=1229411 my @list = @input; @list = sort { ~$b <=> ~$a } @list; Compare(\@list,\@output) or die "@list" if DO_CHECK; }, }); __END__ Rate Eily packz Eily 6495/s -- -66% packz 18967/s 192% --