Sorts a table of data in place.
Standard C Library (libc.a)
void qsort (Base, NumberOfElements, Size, ComparisonPointer)
void * Base;
size_t NumberOfElements, Size;
int (*ComparisonPointer)(const void*, const void*);
The qsort subroutine sorts a table of data in place. It uses the quicker-sort algorithm.
|Base||Points to the element at the base of the table.|
|NumberOfElements||Specifies the number of elements in the table.|
|Size||Specifies the size of each element.|
|ComparisonPointer||Points to the comparison function, which is passed two parameters that point to the objects being compared. The qsort subroutine sorts the array in ascending order according to the comparison function.|
The comparison function compares its parameters and returns a value as follows:
Because the comparison function need not compare every byte, the elements can contain arbitrary data in addition to the values being compared.
Note: If two items are the same when compared, their order in the output of this subroutine is unpredictable.
The pointer to the base of the table should be of type pointer-to-element, and cast to type pointer-to-character.
This subroutine is part of Base Operating System (BOS) Runtime.
The bsearch subroutine, lsearch subroutine.
Searching and Sorting Example Program, Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.