python - How to find an index at which a new item can be inserted into sorted list and keep it sorted? -


a = 132  b = [0, 10, 30, 60, 100, 150, 210, 280, 340, 480, 530] 

i want know a should in 6th position in ordered list b.

what's pythonic way so?

use bisect. it's not beautiful api, it's need.

you'll want use bisect.bisect, returns want.


Comments

Popular posts from this blog

All overlapping substrings matching a java regex -

c++ - Using OpenSSL in a multi-threaded application -

php - Deleting/Renaming a locked file -