Thanks for checking.
It fails if there were three or more zeroes (the test case provided has two zeroes), and if there are no zeroes.
Adding some extra checks seems to fix the issues, and is still close to try1a for speed given the provided test data (sometimes as fast but usually a few percent slower).
swl2 => sub {
my @list = @input;
use List::MoreUtils 0.428;
@list = sort {$a<=>$b} @list;
my $i = List::MoreUtils::bsearchidx {$_ <=> 0} @list;
if ($i < 0) { # no zero
$i = List::MoreUtils::firstidx {$_ >= 0} @list;
}
else {
$i-- while !$list[$i];
$i++;
}
push @list, splice @list, 0, $i;
Compare(\@list,\@output) or die "@list" if DO_CHECK;
},
It will be slower in cases where there are no zeroes, although List::BinarySearch::binsearch_pos could be used to find an insert point for zero in such cases.