Performs a quick sort of an array, overwriting the input array with the sorted elements.
#include <stdlib.h> #include <search.h> void qsort (void *base, size_t num, size_t width, int (*compare)(const void *elem1, const void *elem2));
base
num
width
compare
elem1
and elem2
) and returns a value specifying their relationship:
< 0 |
elem1 less than elem2 |
= 0 |
elem1 equivalent to elem2 |
> 0 |
elem1 greater than elem2 |
elem1
elem2
qsort calls the compare routine one or more times during the sort, passing pointers to two array elements on each call:
compare (( void *) elem1, (void *) elem2);
The function sorts the array in ascending order, as defined by the compare routine. To sort the array in descending order, reverse the sense of greater-than and less-than in the compare routine.
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/stdlib.h | stdlib.h search.h |
clib.lib |