Changed heapsort to qsort to make sure it compiles on Linux.