INFO: qsort() Can Sort Data Structures Based on Multiple Fields (28244)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 5.0
- Microsoft Visual C++, 32-bit Editions 6.0
This article was previously published under Q28244 SUMMARY
The qsort() function in the Microsoft C run-time library does not
restrict the methods an application can use to compare items. When
qsort() compares two data elements, it calls an application-supplied
comparison routine.
To sort an array of structures using more than one field as a key,
create a comparison function that relates the appropriate fields in
each structure and returns a comparison value to indicate the result.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbCRT kbinfo KB28244 |
---|
|