	# heapsort
	
   11	    { A[NR] = $0 }
	
    1	END { hsort(A, NR)
	      for (i = 1; i <= NR; i++)
   11	          { print A[i] }
	    }
	
    1	function hsort(A,n,  i) {
	    for (i = int(n/2); i >= 1; i--)  # phase 1
    5	         { heapify(A, i, n) }
   10	    for (i = n; i > 1; i--) {        # phase 2
   10	         { swap(A, 1, i) }
   10	         { heapify(A, 1, i-1) }
	    }
	}
   15	function heapify(A,left,right,   p,c) {
   24	    for (p = left; (c = 2*p) <= right; p = c) {
	        if (c < right && A[c+1] > A[c])
    8	            { c++ }
	        if (A[p] < A[c])
   18	            { swap(A, c, p) }
	    }
	}
   28	function swap(A,i,j,   t) {
	    t = A[i]; A[i] = A[j]; A[j] = t
	}
