static/js/statechanges.js
function(element, sortedList, sortFunction) {
			var lo = 0;
			var hi = sortedList.length - 1;
			var mid, result;

			while (lo <= hi) {
				mid = lo + Math.floor((hi - lo) / 2);

				result = sortFunction(element, sortedList[mid]);

				if (result < 0) {
					// mid is too high
					hi = mid - 1;
				} else if (result > 0) {
					// mid is too low
					lo = mid + 1;
				} else {
					// mid is the exact index of element
					return mid;
				}
			}

			return null;
		}
function(element, sortedList, sortFunction) {
			var lo = 0;
			var hi = sortedList.length - 1;
			var mid, result;

			while (lo <= hi) {
				mid = lo + Math.floor((hi - lo) / 2);

				result = sortFunction(element, sortedList[mid]);

				if (result < 0) {
					// mid is too high
					hi = mid - 1;
				} else if (result > 0) {
					// mid is too low
					lo = mid + 1;
				} else {
					// mid is the exact index of element
					return mid;
				}
			}

			return null;
		}
function ( element , sortedList , sortFunction ) { var lo = 0 ; var hi = sortedList . length - 1 ; var mid , result ; while ( lo <= hi ) { mid = lo + Math . floor ( ( hi - lo ) / 2 ) ; result = sortFunction ( element , sortedList [ mid ] ) ; if ( result < 0 ) { // mid is too high hi = mid - 1 ; } else if ( result > 0 ) { // mid is too low lo = mid + 1 ; } else { // mid is the exact index of element return mid ; } } return null ; }
returns the index of the element if found, or null otherwise
returns the index of the element if found or null otherwise