If you spend a little time with sort algorithms you realise that although the algorithms vary, the swap and the compare functions is all that's different for sorting different types.
Your example is sorting an array of ints. And the compare method finds the difference of the two numbers.
If this were C++, qsort would be a templated function. But qsort is a C function, so the type system has be bypassed a little. In C, a compare function typically returns zero of equality, less than zero and greater than zero indicate which arg is greater. See strcmp: http://pubs.opengroup.org/onlinepubs/007908799/xsh/strcmp.html
The swap done by calling memset, but for that it needs to know the size of the type, that's why you need to pass in sizeof(int).
The compare function takes pointers to the two numbers to be compared. These are defined to be pointers to anything, void*, and you cast them to the what you know them to be.
Line 9 casts both parameters to pointers to int, then dereferences them, then compares the values. qsort calls this callback whenever it needs to compare two values.