最佳答案
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), (2, 2.1), (3, 1.2), (4, 2.1), (5, 0.01),
(6, 0.5), (7, 0.2), (8, 0.6)]
How may I find the min of the dataset by the comparison of the second number in the tuples only?
i.e.
data[0][1] = 7.57
data[1][1] = 2.1
min( data ) = (5, 0.01)
min( data )
returns (1, 7.57)
, which I accept is correct for the minimum of index 0, but I want minimum of index 1.