I made a qsort function for a larger program. It is to sort by time. I have a class schedule I am working with and found a need to compare time with AM and PM. ie if A is chosen
Assuming you have a function greaterThan, you can implement sortFunction as follows:
greaterThan
sortFunction
int sortFunction(const void *p, const void *q) { if (greaterThan(p, q)) { // p > q return +1; } else if (greaterThan(q, p)) { // p < q return -1; } else { // p == q return 0; } }