HP C/iX Library Reference Manual (30026-90004)

Chapter 5 283
HP C/iX Library Function Descriptions
qsort
qsort
Sorts an array of objects.
Syntax
#include <stdlib.h>
void qsort (void *
base
, size_t
nmemb
, size_t
size
,
int (*
compar
) (const void *, const void *));
Parameters
base
A pointer to an array to be sorted.
nmemb
The number of elements in the array.
size
The size, in bytes, of each element of the array.
compar
A pointer to a user-written comparison function.
Return Values
None.
Description
The qsort function sorts an array of objects. The
size
parameter specifies the size of each
object.
The contents of the array are sorted in ascending order as determined by the user-written
comparison function
compar
, which is called with two arguments that point to the objects
being compared. The function must return an integer less than, equal to, or greater than
zero as a consequence of whether its first argument is to be considered less than, equal to,
or greater than the second.
The order of two members that compare as equal in the sorted array is unspecified.
See Also
ANSI C 4.10.5.2, POSIX.1 8.1