def METHOD_NAME(self, a, x, lo=0, hi=None):
    """
    Function to find the upper bound in an array/list
    Args:
        a (list)  : The list to be searched in
        x (float) : The number whose upper bound is to be found
        lo (int)  : Starting position of the list
        hi (int)  : Ending position of the list
    Returns:
        (int) : The index of upper bound of a number x
    """
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        # Use _lt_ to match the logic in list.sort() and in heapq
        if self.comp(x, a[mid][0]): hi = mid
        else: lo = mid+1
    return lo