update heap sort algorithm