This is an excellent representation of heapsort. Although I found it difficult to grasp the sorting method by code, I found this gif clear and illustrative to understand the steps.