In Python, how do you find the index of the first value greater than a threshold in a sorted list?
I can think of several ways of doing this (linear search, hand-written dichotomy,..), but I’m looking for a clean an reasonably efficient way of doing it. Since it’s probably a pretty common problem, I’m sure experienced SOers can help!
Thanks!
Have a look at bisect.
Compare it with linear search: