implement a heap sort algorithm