Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ qsort(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bsearch(S)

lsearch(S)

sort(C)

string(S)


 qsort(S)                       6 January 1993                       qsort(S)


 Name

    qsort - quicker sort

 Syntax


    cc  . . .  -lc


    #include <stdlib.h>

    void qsort (base, nel, width, compar)
    void *base;
    size_t nel, width;
    int (*compar)();


 Description

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

    The base argument points to the element at the base of the table.  The
    nel argument is the number of elements in the table.  The width argument
    is the size in bytes of each element.  The compar argument is the name of
    the comparison function, which is called with two arguments that point to
    the elements being compared.  The comparison function must return an
    integer less than, equal to, or greater than zero, according to whether
    the first argument is to be considered as less than, equal to, or greater
    than the second argument.

 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, so arbitrary data
    may be contained in the elements in addition to the values being com-
    pared.

    The order in the output of two items which compare as equal is unpredict-
    able.

 See also

    bsearch(S), lsearch(S), sort(C), string(S)

 Standards conformance

    qsort is conformant with:
    AT&T SVID Issue 2;
    X/Open Portability Guide, Issue 3, 1989;
    ANSI X3.159-1989 Programming Language -- C;
    IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C
    Language] (ISO/IEC 9945-1);
    and NIST FIPS 151-1.


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