A comparison function is a callback that establishes an ordering between two elements. It returns a negative value when the first is smaller, zero when they compare equal, and a positive value otherwise. section 11.4
A safe unsigned comparison
The comparator receives two void pointers, converts them to unsigned pointers, and compares the pointed-to values with explicit relational tests. Returning *A - *B is unsafe for integers because the difference can overflow.
Use the callback with generic array algorithms by preserving the element type and ordering assumptions:
- Pass the array address as a void pointer, together with the element count and element size. section 11.4
- Give bsearch a comparator consistent with the ordering already used to sort the array. section 11.4


