Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C programming/stdlib.h/qsort

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

qsort is a function used to sort elements in an array. It is named after the quicksort algorithm, although the C standard does not require it to be implemented using any specific algorithm.http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf ISO/IEC 9899:1999 specification p. 319, § 7.20.5.2 qsort is a generic function that can sort arrays of any size, containing any kind of object (although, if the objects are not the same in size, pointers have to be used) and using any kind of comparison predicate. The genericity, however, comes at the expense of type-safety, since qsort operates on void pointers. Prototype void qsort(void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *)); Behaviour The contents of the array are sorted in order according to a comparison function pointed to by compare. When items compare equal, their order in resulting array is unspecified, meaning qsort is not required to be a stable sort. References External links C++ reference for std::qsort deep