Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ qsort(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

alphasort

bsearch

lsearch, lfind

string

sort



QSORT(3,L)                  AIX Technical Reference                  QSORT(3,L)



-------------------------------------------------------------------------------
qsort



PURPOSE

Sorts a table of data in place.

LIBRARY

Standard C Library (libc.a)

SYNTAX

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

DESCRIPTION

The qsort subroutine sorts a table of data in place.  It uses the
"quicker-sort" algorithm.

The base parameter points to the element at the base of the table.  The nel
parameter is the number of elements in the table.  The compar parameter is the
name of the comparison function.  (See "alphasort" for one such comparison
function.)

The comparison function must compare its parameters and return a value as
follows:

  o If the first parameter is less than the second parameter, compar must
    return a value less than 0.
  o If the first parameter is equal to the second parameter, compar must return
    0.
  o If the first parameter is greater than the second parameter, compar must
    return a value greater than 0.

The comparison function need not compare every byte, so arbitrary data can be
contained in the elements in addition to the values being compared.

Note:  The order in the output of two items that compare equal is
       unpredictable.

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

RELATED INFORMATION

In this book:  "alphasort," "bsearch," "lsearch, lfind," and "string."



Processed November 7, 1990        QSORT(3,L)                                  1





QSORT(3,L)                  AIX Technical Reference                  QSORT(3,L)




The sort command in AIX Operating System Commands Reference.





















































Processed November 7, 1990        QSORT(3,L)                                  2



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