#include <xtend/math.h>
-lxtend
int short_cmp(const short *n1, const short *n2)
n1, n2 Pointers to two short values
This is a function that compares two shorts as a service to polymorphic
functions such as qsort(3), bsearch(3), etc. The address of short_cmp() is
passed as an argument to perform the data type specific comparison on behalf
of the sort of search function.
A value > 0 if *n1 is greater than *n2 A value < 0 if *n1 is less than *n2
0 if the values are equal
short list[LIST_SIZE];
// sizeof(*list) will continue to work if we change the data type
// We'll still need to change the cmp function, though
qsort(list, LIST_SIZE, sizeof(*list),
(int (*)(const void *, const void *))short_cmp);
qsort(3), heapsort(3), mergesort(3), bsearch(3)