The idea is this, the sort function is independent of the algorithm. All the sort process needs to know about your data is the number of elements, the size of each element, how to copy and how to compare elements.
The compare function returns -1 for less, 0 for equals, 1 for greater than. qsort calls it when it needs to compare elements and that is the basis of whether elements are swapped during the sort process.
I feel I haven't said anything that's not already there, but there's not much else to say.