Implemented heap sort algorithm