from bisect import bisect_left items = [5, 8, 2, 3] print(bisect_left(sorted(items), 2))