Sorting algorithms/Radix sort: Difference between revisions

Content added Content deleted
(Added 11l)
Line 9: Line 9:
The primary purpose is to complete the characterization of sort algorithms task.
The primary purpose is to complete the characterization of sort algorithms task.
<br><br>
<br><br>
=={{header|11l}}==
{{trans|Python}}

<lang 11l>F flatten(some_list)
[Int] new_list
L(sub_list) some_list
new_list [+]= sub_list
R new_list

F radix_sort(l, =p = -1, =s = -1)
I s == -1
s = String(max(l)).len
I p == -1
p = s

V i = s - p
I i >= s
R l

V bins = [[Int]()] * 10

L(e) l
bins[Int(String(e).zfill(s)[i])] [+]= e

R flatten(bins.map(b -> radix_sort(b, @p - 1, @s)))

V arr = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]
print(radix_sort(arr))</lang>

{{out}}
<pre>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
</pre>

=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
Line 196: Line 230:
Table sorted.
Table sorted.
</pre>
</pre>

=={{header|Ada}}==
=={{header|Ada}}==