I have a list of tuples and need to delete tuples if its 1st item is matching with 1st item of other tuples in the list. 3rd item may or may not be the same, so I cannot use
The usual way is keying a dict off whatever you want to dedupe by, for example:
>>> a = [(0, 13, 'order1'), (14, 27, 'order2'), (14, 27, 'order2.1'), (0, 13, 'order1'), (28, 41, 'order3')]
>>> print(*{tup[:2]: tup for tup in a}.values())
(0, 13, 'order1') (14, 27, 'order2.1') (28, 41, 'order3')
This is O(n) time complexity, superior to O(n log n) groupby based approaches.