Counting sort algorithm. It's correct only
for array of integers.
Time complexity: O(N).
Time complexity: O(N).
Parameters:
| Name | Type | Description |
|---|---|---|
array |
Array | Array which should be sorted. |
- Source:
Returns:
Sorted array.
- Type
- Array
Example
var sort = require('path-to-algorithms/src/' +
'sorting/countingsort').countingSort;
console.log(sort([2, 5, 1, 3, 4])); // [ 1, 2, 3, 4, 5 ]