code: function binarySearch (comparator, array, key) {
    var low = 0, high = array.length - 1, partition, compare;
    while (low <= high) {
      partition = Math.floor(low + (high - low) / 2);
      compare = comparator(key, array[partition]);
      if (compare < 0) high = partition - 1;
      else if (compare > 0) low = partition + 1;
      else return partition;
    }
    return low;
  }
docs: Binary search, implemented, as always, by taking a [peek at Sedgewick](http://algs4.cs.princeton.edu/11model/BinarySearch.java.html).