    import java.util.Scanner;

    /**
     * Java Implementation of Heap Sort
     * <code>
     * procedure heapsort(a, count) is
     *input: an unordered array a of length count
     *(Build the heap in array a so that largest value is at the root)
     *heapify(a, count)
     *(The following loop maintains the invariants that a[0:end] is a heap and every element
     *beyond end is greater than everything before it (so a[end:count] is in sorted order))
     *end ← count - 1
     *while end > 0 do
     *  (a[0] is the root and largest value. The swap moves it in front of the sorted elements.)
     *  swap(a[end], a[0])
     *  (the heap size is reduced by one)
     *  end ← end - 1
     *  (the swap ruined the heap property, so restore it)
     *  siftDown(a, 0, end)
     * </code>
     * 
     * @author Subham Mishra
     **/
     
    public class HeapSort 

    {    
        private static int N;

        /* Sort Function */

        public static void heapSort(int arr[])

        {       

            heapify(arr);        

            for (int i = N; i > 0; i--)

            {

                swap(arr,0, i);

                N = N-1;

                maxheap(arr, 0);

            }

        }     

        /* Function to build a heap */   

        public static void heapify(int arr[])
        {
            N = arr.length-1;
            for (int i = N/2; i >= 0; i--)
                maxheap(arr, i);        
        }

        /**
        * 
        *Function to swap largest element in heap
        * 
        **/        

        public static void maxheap(int arr[], int i)
        { 
            int left = 2*i ;
            int right = 2*i + 1;
            int max = i;
            if (left <= N && arr[left] > arr[i])
                max = left;
            if (right <= N && arr[right] > arr[max])        
                max = right;
            if (max != i)
            {
                swap(arr, i, max);
                maxheap(arr, max);
            }
        }    

        /**
         * 
        *Function to swap two numbers in an array 
        *
        **/

        public static void swap(int arr[], int i, int j)
        {
           int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp; 
        }    
        
        public static void main(String[] args) 
        {
            Scanner scan = new Scanner( System.in );        
            System.out.println("Heap Sort in java Demo");
            int n, i;    
            System.out.println("Enter number of integer elements");
            n = scan.nextInt();    
            int arr[] = new int[ n ];
             System.out.println("\nEnter "+ n +" integer elements");
            for (i = 0; i < n; i++)
                arr[i] = scan.nextInt();
            heapSort(arr);
            System.out.println("\nElements after sorting ");        
            for (i = 0; i < n; i++)
                System.out.print(arr[i]+" ");            
            System.out.println();            
        }    
    }

@@ -794,24 +794,86 @@
 de%3E%0A     * %0A
+     * For more info : https://en.wikipedia.org/wiki/Heapsort%0A
      * @auth
@@ -889,16 +889,16 @@
  Mishra%0A
-
      **/
@@ -987,27 +987,71 @@
   /*
- Sort Function 
+*%0A         * %0A         * Sort Function%0A         * %0A        *
 */%0A
-%0A
     
@@ -1103,33 +1103,32 @@
        %7B       %0A
-%0A
             heap
@@ -1137,33 +1137,32 @@
 y(arr);        %0A
-%0A
             for 
@@ -1185,17 +1185,16 @@
 0; i--)%0A
-%0A
         
@@ -1199,17 +1199,16 @@
       %7B%0A
-%0A
         
@@ -1231,17 +1231,16 @@
 ,0, i);%0A
-%0A
         
@@ -1256,17 +1256,16 @@
  = N-1;%0A
-%0A
         
@@ -1289,17 +1289,16 @@
 rr, 0);%0A
-%0A
         
@@ -1295,33 +1295,32 @@
 ;%0A            %7D%0A
-%0A
         %7D     %0A%0A
@@ -1314,25 +1314,24 @@
      %7D     %0A
-%0A
         /* F
@@ -1328,17 +1328,39 @@
       /*
- 
+*%0A         * %0A        *
 Function
@@ -1376,16 +1376,37 @@
  a heap 
+%0A        * %0A        *
 */   %0A%0A 

Update HeapSort.java