Find list in nested list with maximum number of highest numbers, Python

  comparison, max, nested-lists, python

I am trying to find the list in nested list, which has the maximum number of highest numbers, as shown bellow:

test_list = [[200,1,100],[50,120,0],[40,300,0]]
desired output = [200,1,100]

[200,1,100] is the winner here, as out of its 3 digits, 2 are higher than the other lists 2 numbers. This would not be sequence sensitive however, for example if:

test_list = [[1,100,200],[1,200,100],[200,1,100],[50,120,0],[40,300,0]]
desired output =  [[1,100,200],[1,200,100],[200,1,100]]

reason being that here all three constitue the "maximum" lineup of digits. Is there anyway other than creating all permutations and comparing them?

Source: Python Questions

LEAVE A COMMENT