// Sort array using heap sort

// main heap sort function
function heapSort(arr) {
	var len = arr.length,
		end = len - 1;

	heapify(arr, len);

	while (end > 0) {
		swap(arr, end--, 0);
		siftDown(arr, 0, end);
	}

	return arr;
}

@@ -224,8 +224,237 @@
  arr;%0A%7D%0A
+%0A// function to make array heap tree%0Afunction heapify(arr, len) %7B%0A%09// break array into root and two sides to create heap tree%0A%09var middle = Math.floor((len - 2)/2);%0A%09while (middle %3E= 0) %7B%0A%09%09siftDown(arr, middle--, len - 1);%0A%09%7D%0A%7D%0A

Add function to make array a heap tree