Sorts an array.
#include <stdlib.h> void qsort(void *base,size_t nmemb, size_t size, int (*compare) (const void *, const void *))
base
A pointer to the array to be sorted.
nmemb
The number of elements.
size
The size of a single element, expressed as a number of characters.
compare
A pointer to a comparison function.
The qsort() function sorts an array using the Quicksort algorithm. It sorts the array without displacing it; the array occupies the same memory it had before the call to qsort().
The compare argument is a pointer to a programmer-supplied compare function. The function takes two pointers to different array elements and compares them based on the key. If the two elements are equal, compare must return a zero.
The compare function must return a negative number if the first element is less than the second. Likewise, the function must return a positive number if the first argument is greater than the second.