NAME

hsort(3) - generic heap sort


SYNOPSIS

    #include <slack/hsort.h>

    void hsort(void *base, size_t nelem, size_t size, int (*cmp)(const void *, const void *))


DESCRIPTION

hsort() is an implementation of the heap sort algorithm. It sorts a table of data in place. base points to the element at the base of the table. nelem is the number of elements in the table. size is the size of the elements in bytes. cmp is the comparison function, which is called with two arguments that point to the elements being compared. As the function must return an integer less than, equal to, or greater than zero, so must the first argument to be considered be less than, equal to, or greater than the second.


NOTES

The comparison function need not compare every byte, so arbitrary data may be contained in the elements in addition to the values being compared.

The order in the output of two items which compare as equal is unpredictable.


MT-Level

MT-Safe


SEE ALSO

qsort(3)


AUTHOR

    Stephen Russell, Department of Computer Science,
    University of Sydney, 2006.
    Australia
    1988 April 28