qsort - quicker sortSYNOPSIS
qsort(base, nel, width, compar) char *base; int (*compar)();DESCRIPTION
NOTES
The pointer to the base of the table should be of type
pointer-to-element, and cast to type pointer-to-character.
The comparison function need not compare every byte, so
arbitrary data may be contained in the elements in addition
to the values being compared.
The order in the output of two items which compare as equal
is unpredictable.
SEE ALSO
sort(1V), bsearch(3), lsearch(3), string(3)
EXAMPLE
The following program sorts a simple array:
static int intcompare(i,j) int *i, *j; { return(*i - *j); } main() { int a[10]; int i; a[0] = 9; a[1] = 8; a[2] = 7; a[3] = 6; a[4] = 5; a[5] = 4; a[6] = 3; a[7] = 2; a[8] = 1; a[9] = 0; qsort(a,10,sizeof(int),intcompare) for (i=0; i<10; i++) printf(" %d",a[i]); printf("\n"); }