qsort()

NAME

qsort() - sort function

SYNOPSIS

#include <stdlib.h>

void qsort (void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) )

DESCRIPTION

The qsort(3) function is a modified partition-exchange sort, or quicksort.

The qsort(3) function sorts an array of nmemb objects, the initial member of which is pointed to by base. The size of each object is specified by size.

The contents of the array base are sorted in ascending order according to a comparison function pointed to by compar, which requires two arguments pointing to the objects being compared.

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

Qsort(3) is not stable, that is, if two members compare as equal, their order in the sorted array is undefined. While qsort(3) does not allocate memory, it is implemented using recursion.

RETURN VALUES

The qsort(3) function returns no value.

SEE ALSO

sort(1)