in reply to Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1
try1a => sub { my $high = my @list = sort { $a <=> $b } @input; my $mid = my $low = 0; $list[$mid = $low + $high >> 1] < 0 ? ($low = $mid + 1) : ($high = $mid) while $low < $high; push @list, splice @list, 0, $low; Compare(\@list,\@output) or die "@list" if DO_CHECK; },
Grumble... I hate speed contests :(
Although that "push" line is quite interesting. perl++
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1
by shmem (Chancellor) on Feb 06, 2019 at 03:15 UTC |