Commit | Line | Data |
---|---|---|
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 | |
11 | qsort \- quicker sort | |
12 | .SH SYNOPSIS | |
13 | .nf | |
183abe36 KB |
14 | .ft B |
15 | #include <stdlib.h> | |
16 | ||
17 | void | |
18 | qsort(void *base, size_t nmemb, size_t size, | |
19 | int (*compar)(const void *, const void *)); | |
20 | .ft R | |
bfbd68e0 KM |
21 | .fi |
22 | .SH DESCRIPTION | |
23 | .I Qsort | |
183abe36 KB |
24 | is an implementation of C.A.R. Hoare's ``quicksort'' algorithm. |
25 | .PP | |
26 | The | |
27 | .I qsort | |
28 | function sorts an array of | |
29 | .I nmemb | |
30 | objects, the initial member of which is pointed to by | |
31 | .IR base . | |
32 | The size of each object is specified by | |
33 | .IR size . | |
34 | .PP | |
35 | The contents of the array are sorted in ascending order according to | |
36 | a comparison function pointed to by | |
37 | .IR compar , | |
38 | which is called with two arguments that point to the objects being | |
39 | compared. | |
40 | .PP | |
41 | The comparison function must return an integer less than, equal to, or | |
42 | greater than zero if the first argument is considered to be respectively | |
bfbd68e0 | 43 | less than, equal to, or greater than the second. |
183abe36 KB |
44 | .PP |
45 | If two members compare as equal, their order in the sorted array is | |
46 | undefined. | |
bfbd68e0 KM |
47 | .SH "SEE ALSO" |
48 | sort(1) | |
183abe36 KB |
49 | .SH STANDARDS |
50 | .B Qsort | |
51 | conforms to ANSI X3.159-1989 (``ANSI C''). | |
1eee95b5 | 52 | .SH BUGS |
183abe36 KB |
53 | The comparison routine may not itself call |
54 | .IR qsort (3). |