qsort is the name of a C standard library function that sorts arrays using a caller-provided comparison function. Other programming languages may provide similar functions by the same name. Name notwithstanding, these functions do not necessarily implement quick-sort, so use the [quicksort] tag instead for questions specifically about the that algorithm. Use [qsort] ONLY for questions about library functions of that name.
qsort
is the name of a C standard library function that sorts arrays of arbitrary element type using a caller-provided comparison function. Other programming languages may provide similar functions by the same name.
Although the name is suggestive of Hoare's "Quick Sort", these functions do not necessarily implement any variation on that algorithm. In particular, the prototypical example -- C's -- is not required by that language's standard to implement any specific algorithm.
On the other hand, qsort
functions' specifications are typically consistent with implemention as Quick Sort. For example, they generally are not specified to be stable sorts, and C's in particular is not specified to be stable. (Standard Quick Sort is not stable.)
In practice, it would be surprising to encounter a qsort
function without these properties common in common with Quick Sort implementations:
- in-place sorting, with no more than O(log n) overhead in the average case.
- performance bounded by O(n log n) in the average case, and no worse than O(n2) in the worst case.