ternary tree heap sort