my general variant of heapsort