code: function(element, sortedList, sortFunction) {
  			// p(index) = val at index is same or larger than element
  			function p(index) {
  				return (sortFunction(element, sortedList[index]) <= 0);
  			}
  
  			var lo = 0;
  			var hi = sortedList.length - 1;
  			var mid, result;
  
  			while (lo < hi) {
  				mid = lo + Math.floor((hi - lo) / 2);
  
  				result = p(mid);
  
  				if (result) {
  					// mid is too high or just right
  					hi = mid;
  				} else {
  					// mid is too low
  					lo = mid + 1;
  				}
  			}
  
  			if (lo < sortedList.length && p(lo)) {
  				return lo;
  			} else {
  				// the element was not found and belongs at the end of the list (possibly 0 if the list is empty)
  				return sortedList.length;
  			}
  		}
docs: returns the index at which the element should be inserted