我读了这个关于如何在元组列表上使用 bisect 的问题,并且只比较元组的第一个值。它有效,但我如何比较两个值?如果 x 的索引 < y 的索引并且 y[0] <= x[0] 或 y[1] <= x[1],则 bisect.bisect_left 返回类似的索引
input:[(2, 2), (3, 1), (5, 6)]
bisect.bisect_left(input, (2, 3)) => 0
bisect.bisect_left(input, (3, 4)) => 1
bisect.bisect_left(input, (5, 5)) => 2