Suppose I have a nested list as the one below:
[[['a'],[24],214,1] ,[['b'],[24],312,1] ,[['a'],[24],3124,1] , [['c'],[24],34,1]]
and suppose I want to remove from the list all the items EXCEPT the one that has the maximum value for item[2] among items sharing the same letter in item[0]
So for example in the previous list I have two items sharing the same letter in item[0]:
[ ['a'],[24],214,1], [['a'],[24],3124,1] ]
and I want to remove the former since it has a lower value for item[2].
The output list should then be:
[ [['b'],[24],312,1] ,[['a'],[24],3124,1] , [['c'],[24],34,1] ]
Can you suggest me a compact way to do it?
As your question is confusing, I have given the possibility of removing both the max and the min elements