Is it a way in Python 3 to binary search in sorted list of lists?
Let's assume I have a list of lists:
list = [['A', 'B', 3], ['C', 'D', 1], ['E', 'F', 2]]
I've sorted it by 3d element in inner list with:
list = sorted(list , key=itemgetter(2))
and now list is
[['C', 'D', 1], ['E', 'F', 2], ['A', 'B', 3]]
And now how can I search in this sorted list with binary search (O(log(n)) time complexity) using element from inner list by which sorting was done? Like
findBy(list, index_of_inner_list, value_of_inner_list_to_find)
Outer list is huge. Inner lists have len 50. And I need to make many queries to extract some elements from outer list based on condition related to inner lists. I was thinking about bisect
but inner arrays would be a problem for it I think.