QSORT(S) UNIX System V QSORT(S)
Name
qsort - quicker sort
Syntax
void qsort ((char *) base, nel, sizeof (*base), compar)
unsigned nel;
int (*compar)( );
Description
The qsort function is an implementation of the quicker-sort
algorithm. It sorts a table of data in place.
base points to the element at the base of the table. nel is
the number of elements in the table. compar is the name of
the comparison function, which is called with two arguments
that point to the elements being compared. The comparison
function must return an integer less than, equal to, or
greater than zero, according to whether the first argument
is to be considered as less than, equal to, or greater than
the second argument.
See Also
bsearch(S), lsearch(S), string(S), sort(C)
Notes
The pointer to the base of the table should be of type
pointer-to-element, and cast to type pointer-to-character.
The comparison function need not compare every byte, so
arbitrary data may be contained in the elements in addition
to the values being compared.
The order in the output of two items which compare as equal
is unpredictable.
Standards Conformance
qsort is conformant with:
AT&T SVID Issue 2, Select Code 307-127;
The X/Open Portability Guide II of January 1987;
ANSI X3.159-198X C Language Draft Standard, May 13,
1988;
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support;
and NIST FIPS 151-1.
(printed 6/20/89)