'Grouping lists based on a certain value in python and then returning the minimum of the group [closed]

I have a list that looks this:

lst = [(1,23,45,18),(1,42,15,5),(1,29,65,91),(2,35,62,7),(2,72,39,6),(2,41,15,81),(3,45,61,23),(3,41,15,69),(3,12,15,1)]

I'd like to group the lists by the first indicee, so group 1 would be:

[(1,23,45,18),(1,42,15,5),(1,29,65,91)]

and then return the list has the minimum value in the 4th indicee (18, 5 or 91). So the result for group 1 would be:

(1,42,15,5)

Ideally the resulting list would be the list of minimums:

final_lst = [(1,42,15,5),(2,72,39,6),(3,12,15,1)]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source