Sorts given array with bucketsort.
Time complexity: O(N) in case the data is with uniform distribution.
Time complexity: O(N) in case the data is with uniform distribution.
Parameters:
| Name | Type | Description |
|---|---|---|
array |
Array | Input array which should be sorted. |
- Source:
Returns:
Sorted array.
- Type
- Array
Example
var sort = require('path-to-algorithms/src/'+
'sorting/bucketsort').bucketSort;
console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]