Standard C Functions


qsort, mt_qsort


Syntax

#include <stdlib.h>
void qsort(void *base, size_t num, size_t width,
            int (*compare)(const void *, const void *));
void mt_qsort(void *base, size_t num, size_t width,
            int (*compare)(const void *, const void *));

Arguments

base      pointer to an array
num       number of elements in the array
width     size of one element in the array (byte unit)
compare   pointer to a comparison function created by the user

Return Value

None

Description

It quick sorts the array. mt_qsort is the multi-thread compatible version of qsort.

The compare argument points to a comparison function created by the user:

int compare(const void *elem1, const void *elem2);

The value returned by the comparison function is:


less than zero
elem1 is less than elem2
equal to zero
elem1 is equal to elem2
greater than zero
elem1 is greater than elem2


Revision History

6/1/99 Added explanation of the multi-thread version