I cant do this Heapsort animation
<p>I still pull my hair until this day because I can't think of the animation for this sorting algorithm in java and i still cry at the corner everytime i try to do it. This is my code can you please help me do some animation here?</p>

<pre><code>public static final int max = 11;

public static void main(String[] args) {

    int[] toSortArray = new int[max];
    toSortArray[0] = 0;

    for (int i = 1; i &lt; max; i++) {

        toSortArray[i] = (int) (Math.random() * 100);
        toSortArray[0]++; 
       int index = i;
        while (toSortArray[index / 2] &lt; toSortArray[index] &amp;&amp; (index / 2) != 0) {
            int temp = toSortArray[index / 2];
            toSortArray[index / 2] = toSortArray[index];
            toSortArray[index] = temp;
            index = index / 2;
        }
    }
    System.out.println("The array to be sorted is:");

    for (int i = 0; i &lt; max; i++) {
        System.out.print(" | " + toSortArray[i]);
    }
    System.out.println(" | ");
    while (toSortArray[0] &gt; 0) {

        int temp = toSortArray[1];
        toSortArray[1] = toSortArray[toSortArray[0]];
        toSortArray[toSortArray[0]] = temp;

        for (int i = 1; i &lt; toSortArray[0]; i++) {

            int index = i;

            while (toSortArray[index / 2] &lt; toSortArray[index] &amp;&amp; (index / 2) != 0) {

                int temp1 = toSortArray[index / 2];
                toSortArray[index / 2] = toSortArray[index];
                toSortArray[index] = temp1;
                index = index / 2;
            }
        }
        toSortArray[0]--;
    }
    System.out.println("The sorted array is: ");
    for (int i = 0; i &lt; max; i++) {
        System.out.print(" | " + toSortArray[i]);
    }
    System.out.println(" | ");
}
</code></pre>