Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > Q

qsort(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

qsort() — quicksort

SYNOPSIS

#include <stdlib.h> void qsort( void *base, size_t nel, size_t size, int (*compar)(const void *, const void *) );

DESCRIPTION

qsort() is an implementation of the quicksort algorithm. It sorts a table of data in place.

base

Pointer to the element at the base of the table.

nel

Number of elements in the table.

size

Size of each element in the table.

compar

Name of the comparison function, which is called with two arguments that point to the elements being compared. The function passed as compar must return an integer less than, equal to, or greater than zero, according to whether its first argument is to be considered less than, equal to, or greater than the second. strcmp() uses this same return convention (see string(3C)).

NOTES

The pointer to the base of the table should be of type pointer-to-element, and cast to type pointer-to-void.

The comparison function need not compare every byte; thus, arbitrary data can 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.

WARNINGS

If size is zero, a divide-by-zero error might be generated.

STANDARDS CONFORMANCE

qsort(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.