INF: Using qsort() to Sort Multiple Fields Within a Structure

ID Number: Q28244

4.00 5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version

7.0, the library routine qsort() does not place any limits on how

items are compared. When qsort needs to decide if one element is equal

to, greater than, or less than another element, it calls a compare

function, which you write. Therefore, if you want to sort an array of

structures by comparing multiple fields within the structures, you

need to write a compare function that examines the appropriate fields

of each structure being compared, then return a compare value

indicating which was greater.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00