Jan-31-2019, 05:03 PM
I have searched and found similar request but not able to nail it down. I have a nested list such as:
[[12, 16], [0, 18], [12, 20], [12, 24], [0, 28], [28, 32], [0, 36], [12, 40], [32, 44], [12, 48]]I am attempting to get the pair of numbers which contain the min value for the first element and the max for second. In the case above the correct return should be [0,36]. I have been testing with the below statement. This doesn't seem to give back what I expected, I know I maybe missing something. When I execute the statement, I get [0, 18], or the first instance of the min value. Other than writing several loops to get the desired result, is there another way? Thanks
min(alist, key=lambda item: (item[0], -item[1]))