aboutsummaryrefslogtreecommitdiff
path: root/src/util/array.py
blob: bb4eee3165893247c6498c66513abff54b0b067b (plain)
1
2
3
4
5
def insert_position(x, xs, is_reversed: bool) -> int:
    for i, y in enumerate(xs):
        if is_reversed and x >= y or not is_reversed and x <= y:
            return i
    return len(xs)