def binary_search(lst, key):
    """searches the list for the key. if the key is present,
    the function returns the index of the key. Otherwise it returns
    -low-1. The list must be sorted"""
    lst.sort()
    low = 0
    high = len(lst) - 1
    while low <= high:
        mid = low + (high - low) //2
        if lst[mid] == key:
            return mid
        if lst[mid] < key:
            low = mid + 1
        else:
            hihg = mid - 1
    return -low - 1