Consider the following list of tuples:
transactions = [ ('GBP.USD', '2022-04-29'), ('SNOW', '2022-04-26'), ('SHOP', '2022-04-21'), ('GBP.USD', '2022-04-27'), ('MSFT', '2022-04-11'), ('MSFT', '2022-04-21'), ('SHOP', '2022-04-25')]I can get the tuple with the minimum date like this:
min(transactions, key=lambda x: x[1])This returns a single tuple:
('MSFT', '2022-04-11')I need to return the minimum date of any duplicates along with all unique values. So my output should be this:
[ ('SNOW', '2022-04-26'), ('SHOP', '2022-04-21'), ('GBP.USD', '2022-04-27'), ('MSFT', '2022-04-11'),]How can I do this?