Implemented heap sort