Jump to content

Sorting algorithms/Permutation sort: Difference between revisions

Added 11l
(Added Arturo implementation)
(Added 11l)
Line 13:
'''done'''
<br><br>
=={{header|11l}}==
<lang 11l>F is_sorted(arr)
L(i) 1..arr.len-1
I arr[i-1] > arr[i]
R 0B
R 1B
 
F permutation_sort(&arr)
L !is_sorted(arr)
arr.next_permutation()
 
V arr = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]
permutation_sort(&arr)
print(arr)</lang>
 
{{out}}
<pre>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
</pre>
 
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
Line 275 ⟶ 295:
sorted in +3467024 permutations
</pre>
 
=={{header|ActionScript}}==
<lang ActionScript>//recursively builds the permutations of permutable, appended to front, and returns the first sorted permutation it encounters
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.