Sorting algorithms/Counting sort: Difference between revisions
Content added Content deleted
m (→{{header|J}}: fix lang tags) |
m (Fixed lang tags.) |
||
Line 58: | Line 58: | ||
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} |
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} |
||
<lang |
<lang algol68>PROC counting sort mm = (REF[]INT array, INT min, max)VOID: |
||
( |
( |
||
INT z := LWB array - 1; |
INT z := LWB array - 1; |
||
Line 299: | Line 299: | ||
end. |
end. |
||
cnt # min+i.#cnt |
cnt # min+i.#cnt |
||
⚫ | |||
) |
|||
⚫ | |||
'''Example:''' |
'''Example:''' |
||
<lang j> ] a =. _3 + 20 ?@$ 10 |
<lang j> ] a =. _3 + 20 ?@$ 10 |
||
Line 306: | Line 305: | ||
csort a |
csort a |
||
_3 _2 _2 _1 _1 _1 0 1 1 3 3 4 4 4 4 4 5 5 6 6 |
_3 _2 _2 _1 _1 _1 0 1 1 3 3 4 4 4 4 4 5 5 6 6</lang> |
||
</lang> |
|||
=={{header|Java}}== |
=={{header|Java}}== |
||
Line 327: | Line 325: | ||
=={{header|M4}}== |
=={{header|M4}}== |
||
<lang M4> |
<lang M4>divert(-1) |
||
divert(-1) |
|||
define(`randSeed',141592653) |
define(`randSeed',141592653) |
||
Line 363: | Line 360: | ||
show(`a') |
show(`a') |
||
countingsort(`a',0,99) |
countingsort(`a',0,99) |
||
show(`a') |
show(`a')</lang> |
||
</lang> |
|||
=={{header|Modula-3}}== |
=={{header|Modula-3}}== |
||
Line 612: | Line 608: | ||
=={{header|Slate}}== |
=={{header|Slate}}== |
||
⚫ | |||
<lang slate> |
|||
⚫ | |||
[| counts index | |
[| counts index | |
||
min `defaultsTo: (s reduce: #min: `er). |
min `defaultsTo: (s reduce: #min: `er). |