Default comparator function used for sorting
first element to compare
second element to compare
a negative number if a < b, 0 if a = b, a positive number if a > b
Private Readonly bucketPrivate Readonly defaultPrivate Readonly sizePrivate Readonly valuesStatic defaultStatic sortSorts the array using the BucketSort algorithm. Static method, no need to instantiate class
the array to be sorted
the comparator function used for sorting, defaults to numerical comparison
Default comparator function used for sorting
first element to compare
second element to compare
a negative number if a < b, 0 if a = b, a positive number if a > b
the number of buckets to use, defaults to 10
a new array with the elements sorted
Generated using TypeDoc
BucketSort is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm or by recursively applying the bucket sorting algorithm.
Bucket sort is mainly useful when input is uniformly distributed over a range. The algorithm has a time complexity of O(n + k) in the best and average case, where n is the number of elements and k is the number of buckets. The worst-case time complexity is O(n^2) when all elements are placed in the same bucket.
Note: This implementation is optimized for numeric values. For non-numeric types, consider using other sorting algorithms.
Example
Example