// 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;
}

// 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;
}

// function to make array heap tree
function heapify(arr, len) {
	// break array into root and two sides to create heap tree
	var middle = Math.floor((len - 2)/2);
	while (middle >= 0) {
		siftDown(arr, middle--, len - 1);
	}
}

Add function to make array a heap tree
Add function to make array a heap tree
