1 .\" Copyright (c) 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)radixsort.3 8.2 (Berkeley) 1/27/94
33 .\" $FreeBSD: src/lib/libc/stdlib/radixsort.3,v 1.9 2001/09/07 14:46:35 asmodai Exp $
47 .Fn radixsort "const unsigned char **base" "int nmemb" "const unsigned char *table" "unsigned endbyte"
49 .Fn sradixsort "const unsigned char **base" "int nmemb" "const unsigned char *table" "unsigned endbyte"
56 are implementations of radix sort.
58 These functions sort an array of pointers to byte strings, the initial
59 member of which is referenced by
61 The byte strings may contain any values; the end of each string
62 is denoted by the user-specified value
65 Applications may specify a sort order by providing the
71 must reference an array of
73 + 1 bytes which contains the sort
74 weight of each possible byte value.
75 The end-of-string byte must have a sort weight of 0 or 255
76 (for sorting in reverse order).
77 More than one byte may have the same sort weight.
81 is useful for applications which wish to sort different characters
82 equally, for example, providing a table with the same weights
83 for A-Z as for a-z will result in a case-insensitive sort.
86 is NULL, the contents of the array are sorted in ascending order
89 order of the byte strings they reference and
91 has a sorting weight of 0.
95 function is stable, that is, if two elements compare as equal, their
96 order in the sorted array is unchanged.
99 function uses additional memory sufficient to hold
105 function is not stable, but uses no additional memory.
107 These functions are variants of most-significant-byte radix sorting; in
108 particular, see D.E. Knuth's Algorithm R and section 5.2.5, exercise 10.
109 They take linear time relative to the number of bytes in the strings.
127 for any of the errors specified for the library routine
136 .%B "The Art of Computer Programming"
137 .%T "Sorting and Searching"
144 .%T "Three Partition Refinement Algorithms"
145 .%J "SIAM J. Comput."
152 .%B "Engineering Radix Sort"
153 .%T "Computing Systems"
160 function first appeared in