I want to find the minimum of a list of tuples sorting by a given column. I have some data arranged as a list of 2-tuples for example.
data = [ (1, 7.57), (
Even though Lev's answer is correct, I wanted to add the sort Method as well, in case someone is interested in the first n minimas.
One thing to consider is that the min operation's runtime is O(N) where the sort's is O(N Log N)
data = [ (1, 7.57), (2, 2.1), (3, 1.2), (4, 2.1), (5, 0.01), (6, 0.5), (7, 0.2), (8, 0.6)]
data.sort(key=lambda x:x[1])
print data
>>> [(5, 0.01), (7, 0.2), (6, 0.5), (8, 0.6), (3, 1.2), (2, 2.1), (4, 2.1), (1, 7.57)]
https://www.ics.uci.edu/~pattis/ICS-33/lectures/complexitypython.txt