Sorting algorithms/Insertion sort: Difference between revisions

→‎{{header|Javascript}}: An insertion sort should have the property that nearly sorted lists sort in linear time and the splice method didnt work that way.
(→‎{{header|Perl}}: Use a range instead of a for loop on $i)
(→‎{{header|Javascript}}: An insertion sort should have the property that nearly sorted lists sort in linear time and the splice method didnt work that way.)
Line 656:
function insertionSort (a) {
for (var i = 0; i < a.length; i++) {
for (var jk = 0; j < a[i]; j++) {
for (var j = if (a[i]; j > 0 && k < a[j - 1]); {j--)
var ka[j] = a.splice(i,[j - 1)];
a.splice([j,] 0,= k);
break;
}
}
}
return a;
Anonymous user