Update: heap sort solution.