Sorting algorithms/Insertion sort: Difference between revisions
Content added Content deleted
PatGarrett (talk | contribs) m (→{{header|360 Assembly}}: add a comment) |
|||
Line 1,829: | Line 1,829: | ||
<lang Oforth>: insertionSort(a) |
<lang Oforth>: insertionSort(a) |
||
{ |
|||
| l i j v | |
| l i j v | |
||
a asListBuffer ->l |
|||
2 l size for: i [ |
2 l size for: i [ |
||
l at(i) ->v |
l at(i) ->v |
||
i 1 |
i 1- ->j |
||
while(j) [ |
while(j) [ |
||
l at(j) dup v <= ifTrue: [ drop break ] |
l at(j) dup v <= ifTrue: [ drop break ] |
||
j 1 |
j 1+ swap l put |
||
j 1 |
j 1- ->j |
||
] |
] |
||
l put(j 1 +, v) |
l put(j 1 +, v) |
||
] |
] |
||
l |
l ;</lang> |
||
}</lang> |
|||
{{out}} |
{{out}} |