the heap sort algorithm in max-heap