Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ qsort(3C) — HP-UX 5.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sort(1)

bsearch(3C)

lsearch(3C)

string(3C)

QSORT(3C)  —  HP-UX

NAME

qsort − quicker sort

SYNOPSIS

void qsort ((char ∗) base, nel, sizeof (∗base), compar)
unsigned nel;
int (∗compar)( );

DESCRIPTION

Qsort is an implementation of the quicker-sort algorithm.  It sorts a table of data in place. 

Base points to the element at the base of the table.  Nel is the number of elements in the table.  Compar is the 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 as a consequence of whether its first argument is to be considered less than, equal to, or greater than the second.  This is the same return convention that strcmp uses. 

NOTES

The pointer to the base of the table should be of type pointer-to-element, and cast to type pointer-to-character. 
The comparison function need not compare every byte, so arbitrary data may 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.

SEE ALSO

sort(1), bsearch(3C), lsearch(3C), string(3C). 

BUGS

If width is zero, a divide-by-zero error may be generated. 

Hewlett-Packard Company  —  Version B.1,  April 12, 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026