COHERENT manpages
This page displays the COHERENT manpage for shellsort() [Sort arrays in memory].
List of available manpages
Index
shellsort() -- General Function (libc) Sort arrays in memory void shellsort(data, n, size, comp) char *data; int n, size; int (*comp)(); shellsort() is a generalized algorithm for sorting arrays of data in memory, using D. L. Shell's sorting method. shellsort() works with a sequential array of memory called data, which is divided into n parts of size bytes each. In practice, data is usually an array of pointers or structures, and size is the sizeof the pointer or structure. Each routine compares pairs of items and exchanges them as required. The user-supplied routine to which comp points performs the comparison. It is called repeatedly, as follows: (*comp)(p1, p2) char *p1, *p2; Here, p1 and p2 each point to a block of size bytes in the data array. In practice, they are usually pointers to pointers or pointers to structures. The comparison routine must return a negative, zero, or positive result, depending on whether p1 is less than, equal to, or greater than p2, respectively. Example For an example of how to use this routine, see the entry for string. See Also libc, qsort() The Art of Computer Programming, vol. 3, pp. 84ff, 114ff Notes For a discussion of how the shellsort algorithm differs from that used by qsort(), see the Lexicon entry for qsort().