Suppose I have a list A and when I insert tuple B, I get list C. List A is a sorted list based on the 3rd number of each tuple
In short: How do I insert this tuple into list A while keeping the list sorted based on the 3rd value.
INSERT TO NOT SORT this is not the same question as this one How to sort a list/tuple of lists/tuples by the element at a given index?
because sorting the list is simply too slow.
A = [(1, 2, 1),(1, 2, 2),(1, 2, 3),(1, 2, 5)]
insert --> B: (1, 2, 4)
C = [(1, 2, 1),(1, 2, 2),(1, 2, 3),(1, 2, 4),(1, 2, 5)]