Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
→{{header|Perl}}: Use a range instead of a for loop on $i
(→{{header|Perl}}: an insertion sort should become O(n) when already sorted so the splice method from before wouldnt be good.) |
(→{{header|Perl}}: Use a range instead of a for loop on $i) |
||
Line 840:
sub insertion_sort {
my (@a, $i, $j, $k) = @_;
for
$k = $a[$i];
for ($j = $i
$a[$j
}
$a[$j
}
@a;
|