Sorting algorithms/Counting sort: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: removed need for scoped type variables) |
|||
Line 429: | Line 429: | ||
True |
True |
||
</lang> |
</lang> |
||
Using a list: |
|||
{{works with|Python|2.6}} |
|||
<lang python>def countingSort(a, min, max): |
|||
cnt = [0] * (max - min + 1) |
|||
for x in a: |
|||
cnt[x - min] += 1 |
|||
return [x for x, n in enumerate(cnt, start=min) |
|||
for i in xrange(n)]</lang> |
|||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |