Builds a max-heap from the list and repeatedly extracts the maximum element and rebuilds the heap.
Explain code with DocComment! Try out your own code!