heap sort works