Sorting algorithms/Counting sort: Difference between revisions
Content added Content deleted
(J: alternate implementation) |
m (→{{header|J}}) |
||
Line 598: | Line 598: | ||
<lang J>csort=: (+/@(=/) # ]) >./ (] + 1 i.@+ -) <./</lang> |
<lang J>csort=: (+/@(=/) # ]) >./ (] + 1 i.@+ -) <./</lang> |
||
And note that this can be simplified if the range is known in advance. |
And note that this can be simplified if the range is known in advance (which would probably be the case -- this sorting mechanism is practical when we have a small fixed range of values that we are sorting. |
||
'''Example:''' |
'''Example:''' |