Sorting algorithms/Patience sort: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added syntax colouring the hard way |
Alextretyak (talk | contribs) Added 11l |
||
Line 9: | Line 9: | ||
:* [[Longest increasing subsequence]] |
:* [[Longest increasing subsequence]] |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Kotlin}} |
|||
<lang 11l>F patience_sort(&arr) |
|||
I arr.len < 2 {R} |
|||
[[Int]] piles |
|||
L(el) arr |
|||
L(pile) piles |
|||
I pile.last > el |
|||
pile.append(el) |
|||
L.break |
|||
L.was_no_break |
|||
piles.append([el]) |
|||
L(i) 0 .< arr.len |
|||
V min = piles[0].last |
|||
V minPileIndex = 0 |
|||
L(j) 1 .< piles.len |
|||
I piles[j].last < min |
|||
min = piles[j].last |
|||
minPileIndex = j |
|||
arr[i] = min |
|||
V& minPile = piles[minPileIndex] |
|||
minPile.pop() |
|||
I minPile.empty |
|||
piles.pop(minPileIndex) |
|||
V iArr = [4, 65, 2, -31, 0, 99, 83, 782, 1] |
|||
patience_sort(&iArr) |
|||
print(iArr)</lang> |
|||
{{out}} |
|||
<pre> |
|||
[-31, 0, 1, 2, 4, 65, 83, 99, 782] |
|||
</pre> |
|||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
Line 376: | Line 413: | ||
.include "../includeARM64.inc" |
.include "../includeARM64.inc" |
||
</lang> |
</lang> |
||
=={{header|ARM Assembly}}== |
=={{header|ARM Assembly}}== |
||
{{works with|as|Raspberry Pi}} |
{{works with|as|Raspberry Pi}} |