I want to get the minimal element of a list of list of tuples
a = [[(1, 0), (2, 0), (1, 1)], [(2, 0), (1, 1), (1, 0)], [(1, 1), (1, 0), (2, 0)]]
in lexicographic order, so that [(1,1),(1,0),(2,0)]] < [(1,0),(2,0),(1,1)]
,
since the 0-th entry of the tuple has the greater priority, that is 1,1,2 < 1,2,1
,
and the 1-st entry has less priority.
min(a)
returns [(1, 0), (2, 0), (1, 1)]
, which of course is not correct.
I only need the index of the minimal element, so an incorrect version would be
print(min(range(len(a)), key=lambda i: a[i]))
(both minimal element and index only methods would be appreciated).
Of course one could write a custom loop with zip or something, but I would like a solution with little overhead.