Sorting algorithms/Insertion sort: Difference between revisions

added Yorick
m (Mark as using wikipedia content (the algorithm description))
(added Yorick)
Line 1,065:
<45,58,69,74,82,82,88,89,104,112>
</pre>
 
=={{header|Yorick}}==
Based on pseudocode, except using 1-based arrays.
<lang yorick>func insertionSort(&A) {
for(i = 2; i <= numberof(A); i++) {
value = A(i);
j = i - 1;
while(j >= 1 && A(j) > value) {
A(j+1) = A(j);
j--;
}
A(j+1) = value;
}
}</lang>
Anonymous user