forgot stdlib include line
[unix-history] / usr / src / lib / libc / stdlib / qsort.3
CommitLineData
183abe36
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
bfbd68e0 3.\"
183abe36
KB
4.\" %sccs.include.redist.man%
5.\"
6.\" @(#)qsort.3 6.3 (Berkeley) %G%
bfbd68e0 7.\"
dc15bb49 8.TH QSORT 3 ""
bfbd68e0
KM
9.UC 4
10.SH NAME
11qsort \- quicker sort
12.SH SYNOPSIS
13.nf
183abe36
KB
14.ft B
15#include <stdlib.h>
16
17void
18qsort(void *base, size_t nmemb, size_t size,
19int (*compar)(const void *, const void *));
20.ft R
bfbd68e0
KM
21.fi
22.SH DESCRIPTION
23.I Qsort
183abe36
KB
24is an implementation of C.A.R. Hoare's ``quicksort'' algorithm.
25.PP
26The
27.I qsort
28function sorts an array of
29.I nmemb
30objects, the initial member of which is pointed to by
31.IR base .
32The size of each object is specified by
33.IR size .
34.PP
35The contents of the array are sorted in ascending order according to
36a comparison function pointed to by
37.IR compar ,
38which is called with two arguments that point to the objects being
39compared.
40.PP
41The comparison function must return an integer less than, equal to, or
42greater than zero if the first argument is considered to be respectively
bfbd68e0 43less than, equal to, or greater than the second.
183abe36
KB
44.PP
45If two members compare as equal, their order in the sorted array is
46undefined.
bfbd68e0
KM
47.SH "SEE ALSO"
48sort(1)
183abe36
KB
49.SH STANDARDS
50.B Qsort
51conforms to ANSI X3.159-1989 (``ANSI C'').
1eee95b5 52.SH BUGS
183abe36
KB
53The comparison routine may not itself call
54.IR qsort (3).