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
defaultPrivate
Readonly
sizePrivate
Readonly
valuesStatic
defaultStatic
sortSorts the array using the QuickSort 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
a new array with the elements sorted
Generated using TypeDoc
QuickSort is a method of sorting an array by recursively dividing the array into smaller subarrays. It is a divide-and-conquer algorithm that selects a 'pivot' element from the array and partitions the other elements into two sub-arrays according to whether they are less than or greater than the pivot. The sub-arrays are then sorted recursively. The base case of the recursion is an array of zero or one element, which is guaranteed to be sorted. The pivot selection and partitioning steps can be done in different ways and the efficiency of the algorithm depends on the choice of these steps.
The worst-case time complexity of QuickSort is O(n^2), but the average-case time complexity is O(n log n) and the best-case time complexity is O(n log n).
Example
Example