Sorting algorithms/Counting sort: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added syntax colouring the hard way)
(Added Arturo implementation)
Line 646: Line 646:
.include "../affichage.inc"
.include "../affichage.inc"
</lang>
</lang>
=={{header|Arturo}}==

<lang rebol>countingSort: function [items, minimum, maximum][
a: new items
rng: inc maximum - minimum
cnt: array.of: rng 0
z: 0

loop 0..dec size a 'i [
mm: a\[i]-minimum
cnt\[mm]: cnt\[mm] + 1
]

loop minimum..maximum 'i [
loop 0..dec cnt\[i-minimum] 'j [
a\[z]: i
z: z + 1
]
]
return a
]

print countingSort [3 1 2 8 5 7 9 4 6] 1 9</lang>

{{out}}

<pre>1 2 3 4 5 6 7 8 9</pre>

=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
contributed by Laszlo on the ahk [http://www.autohotkey.com/forum/post-276465.html#276465 forum]
contributed by Laszlo on the ahk [http://www.autohotkey.com/forum/post-276465.html#276465 forum]