cmpthese (-2, { sortfirst => sub { my @list = -5..5; @list = sort { $a <=> $b } @list; @list = ((grep { $_ >= 0 } @list), (grep { $_ < 0 } @list)); DO_CHECK and (Compare (\@list, [0..5, -5..-1]) or die "@list"); }, grepfirst => sub { my @list = -5..5; my @pos = grep { $_ >= 0 } @list; my @neg = grep { $_ < 0 } @list; @list = ((sort { $a <=> $b } @pos), (sort { $a <=> $b } @neg)); DO_CHECK and (Compare (\@list, [0..5, -5..-1]) or die "@list"); }, packunpck => sub { my @list = map { unpack "l>", $_ } sort map { pack "l>", $_ } -5..5; DO_CHECK and (Compare (\@list, [0..5, -5..-1]) or die "@list"); }, pryrt => sub { my @list = -5..5; sub sgn { $_[0] < 0 ? -1 : 1 } @list = sort { (sgn ($b) <=> sgn ($a)) || ($a <=> $b) } @list; DO_CHECK and (Compare (\@list, [0..5, -5..-1]) or die "@list"); }, choroba => sub { my @list = -5..5; @list = sort { ((-1, 0, 1)[$a <=> 0] <=> (-1, 0, 1)[$b <=> 0]) || ($a <=> $b) } @list; DO_CHECK and (Compare (\@list, [0..5, -5..-1]) or die "@list"); }, });