Fix bug in heapify.

Choose the extreme of either left or right instead of always the right if right happens to be more extreme than i.