Sorting algorithms/Insertion sort: Difference between revisions
Content added Content deleted
(→{{header|C}}: Keep indexing the same as the shell sort) |
(→{{header|Perl}}: an insertion sort should become O(n) when already sorted so the splice method from before wouldnt be good.) |
||
Line 839:
<lang perl>
sub insertion_sort {
my (@a, $i, $j, $k) = @_;
for
for ($j = $i
$a[$j + 1]
last;▼
}
}
@a;
}
my @a = (4, 65, 2, -31, 0, 99, 83, 782, 1);
|