Sorting algorithms/Counting sort: Difference between revisions
Content added Content deleted
(Added PowerShell) |
No edit summary |
||
Line 1,960: | Line 1,960: | ||
after count_sort |
after count_sort |
||
1 5 5 13 15 17 19 21 777 888 999</pre> |
1 5 5 13 15 17 19 21 777 888 999</pre> |
||
=={{header|Ring}}== |
|||
<lang ring> |
|||
aList = [4, 65, 2, 99, 83, 782, 1] |
|||
see countingSort(aList, 1, 782) |
|||
func countingSort f, min, max |
|||
count = list(max-min+1) |
|||
for i = min to max |
|||
count[i] = 0 |
|||
next |
|||
for i = 1 to len(f) |
|||
count[ f[i] ] = count[ f[i] ] + 1 |
|||
next |
|||
z = 1 |
|||
for i = min to max |
|||
while count[i] > 0 |
|||
f[z] = i |
|||
z = z + 1 |
|||
count[i] = count[i] - 1 |
|||
end |
|||
next |
|||
return f |
|||
</lang> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |