|
|
1.1 root 1: .\" Copyright (c) 1990 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted
5: .\" provided that: (1) source distributions retain this entire copyright
6: .\" notice and comment, and (2) distributions including binaries display
7: .\" the following acknowledgement: ``This product includes software
8: .\" developed by the University of California, Berkeley and its contributors''
9: .\" in the documentation or other materials provided with the distribution
10: .\" and in all advertising materials mentioning features or use of this
11: .\" software. Neither the name of the University nor the names of its
12: .\" contributors may be used to endorse or promote products derived
13: .\" from this software without specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15: .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)qsort.3 6.3 (Berkeley) 5/16/90
19: .\"
20: .TH QSORT 3 "May 16, 1990"
21: .UC 4
22: .SH NAME
23: qsort \- quicker sort
24: .SH SYNOPSIS
25: .nf
26: .ft B
27: #include <stdlib.h>
28:
29: void
30: qsort(void *base, size_t nmemb, size_t size,
31: int (*compar)(const void *, const void *));
32: .ft R
33: .fi
34: .SH DESCRIPTION
35: .I Qsort
36: is an implementation of C.A.R. Hoare's ``quicksort'' algorithm.
37: .PP
38: The
39: .I qsort
40: function sorts an array of
41: .I nmemb
42: objects, the initial member of which is pointed to by
43: .IR base .
44: The size of each object is specified by
45: .IR size .
46: .PP
47: The contents of the array are sorted in ascending order according to
48: a comparison function pointed to by
49: .IR compar ,
50: which is called with two arguments that point to the objects being
51: compared.
52: .PP
53: The comparison function must return an integer less than, equal to, or
54: greater than zero if the first argument is considered to be respectively
55: less than, equal to, or greater than the second.
56: .PP
57: If two members compare as equal, their order in the sorted array is
58: undefined.
59: .SH "SEE ALSO"
60: sort(1)
61: .SH STANDARDS
62: .B Qsort
63: conforms to ANSI X3.159-1989 (``ANSI C'').
64: .SH BUGS
65: The comparison routine may not itself call
66: .IR qsort (3).
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.