INFO: qsort() Can Sort Data Structures Based on Multiple Fields

ID: Q28244

The information to this article applies to:

The C Run-Time (CRT), included with:Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, 6.0axMicrosoft C for OS/2, versions 5.1, 6.0, 6.0aMicrosoft C/C++ for MS-DOS, version 7.0Microsoft Visual C++ for Windows, 16-bit edition, versions 1.01.5Microsoft Visual C++, 32-bit Editions, versions 1.02.04.05.06.0

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.


MORE INFORMATION


REFERENCES

Additional query words:

Keywords : kbCRT kbVC kbVC100 kbVC150 kbVC200 kbVC400 kbVC500 kbVC600
Version :
Platform : MS-DOS NT OS/2 WINDOWS
Issue type : kbinfo


Last Reviewed: June 18, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.