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.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array
|
Input array which should be sorted. |
Returns:
- Type:
-
Array
Sorted 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 ]