I have a list of the following tupelets (all in the same format) which I have generated by querying a database:
('topic1', 'Will', 5),
('topic1', 'John', 120),
('topic1', 'John', 15),
('topic8378', 'John', 1),
('topic8378', 'Will', 10),
('topic8378', 'John', 10),
('topic8378', 'Jessica', 5),
('topic8378', 'Will', 1),
('topic15', 'Will', 1),
('topic15', 'John', 1),
('topic15', 'Will', 1),
('topic15', 'Will', 1),
('topic15', 'John', 1),
('topic15', 'John', 1),
('blah10', 'Jessica', 8),
('blah10', 'John', 18),
The third value of these dictionaries is an 'amount' field. I want to accumulate a new list of tupelets by adding total amounts for each person in each topic, so that it (for example) returns a simplified total list per topic (reverse sorted in a list):
('topic1', 'John', 135)
('topic1', 'Will', 10)
('topic8378', 'John', 11)
('topic8378', 'Will', 10)
('topic8378', 'Jessica', 5)
('topic15', 'Will', 3)
('topic15', 'John', 3)
('blah10', 'John', 18)
('blah10', 'Jessica, 8)
Should I use itemgetter in this scenario? What is the best way to cross-check duplicates and accumulate totals for the middle field?