Less than 1 minute
Home > @hz-9/algorithm > bucketSort
bucketSort() function
Bucket sort algorithm.
桶排序。
Time complexity: O(n)
Signature:
bucketSort: <T>(list: T[], compareFu?: CompareFn<number>, bucketSize?: number, toNumber?: ToNumberFn<T>) => T[]Parameters
Parameter | Type | Description |
|---|---|---|
list | T[] | The array to be sorted. |
compareFu | CompareFn<number> | (Optional) The comparison function used to determine the order of the elements. |
bucketSize | number | (Optional) The size of each bucket. |
toNumber | ToNumberFn<T> | (Optional) The function used to convert elements to numbers. |
Returns:
T[]
- The sorted array. (Is not original array)