finish heap sort code