Sorting algorithms/Cocktail sort with shifting bounds: Difference between revisions

Added 11l
(Added 11l)
Line 88:
:*   [https://rosettacode.org/wiki/Sorting_algorithms/Cocktail_sort cocktail sort]
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F cocktailshiftingbounds(&A)
V beginIdx = 0
V endIdx = A.len - 1
 
L beginIdx <= endIdx
V newBeginIdx = endIdx
V newEndIdx = beginIdx
L(ii) beginIdx .< endIdx
I A[ii] > A[ii + 1]
swap(&A[ii + 1], &A[ii])
newEndIdx = ii
endIdx = newEndIdx
 
L(ii) (endIdx .< beginIdx - 1).step(-1)
I A[ii] > A[ii + 1]
swap(&A[ii + 1], &A[ii])
newBeginIdx = ii
beginIdx = newBeginIdx + 1
 
V test1 = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]
cocktailshiftingbounds(&test1)
print(test1)</lang>
 
{{out}}
<pre>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
</pre>
 
=={{header|360 Assembly}}==
Line 180 ⟶ 211:
-31 0 1 2 2 4 45 58 65 69 74 82 82 83 88 89 99 104 112 782
</pre>
 
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
1,481

edits