I have a list of dicts of the structure
list_of_dicts = [
{'apples': 123, 'bananas': '556685', 'date': some_date},
{'apples': 99, 'bananas': '556685', 'date': some_date},
{'apples': 99, 'bananas': '556685', 'date': some_other_date},
{'apples': 88, 'bananas': '2345566', 'date': some_other_date}]
plus a few other fields that do not need to be sorted by.
I've already sorted by apples and date, but I am brainfarting on the idea of how to get a list of only the dicts with the most apples per day a lá an SQL query
SELECT max(apples), from TABLE where location in (list of location names) group by date
to get something like
[ {'apples': 123, 'bananas': '556685' 'date': some_date}, {'apples': 99, 'bananas': '556685' 'date': some_other_date}]
I've already tried b = max(temp_top, key = lambda f: (max(f['apples']), f['date']))
but that gives me the dictionary with the most apples over all while I'm trying to get the most apples for each day.