Returns index of x in a, or -1 if x not in a.

    Arguments:
      a -- ordered numeric sequence
      x -- element to search within a
      lo -- lowest index to consider in search*
      hi -- highest index to consider in search*

    *bisect.bisect_left capability that we don't need to loose.

def BSearch(a, x, lo=0, hi=None):
    """Returns index of x in a, or -1 if x not in a.

    Arguments:
      a -- ordered numeric sequence
      x -- element to search within a
      lo -- lowest index to consider in search*
      hi -- highest index to consider in search*

    *bisect.bisect_left capability that we don't need to loose."""
    if len(a) == 0: return -1
    hi = hi if hi is not None else len(a)
    pos = bisect_left(a, x, lo, hi)
    return pos if pos != hi and a[pos] == x else -1