Consider a list of dicts with a date property and an amount property:
transactions = [
    {'date': '2013-05-12', 'amount': 1723},
    {'date': '2013-07-23', 'amount': 4523},
    {'date': '2013-02-01', 'amount': 2984},
]
I would like to add a balance property, but to do so I must iterate over the list in date order:
balance = 0
for t in transactsions:    # Order by date
    balance += t['amount']
    t['balance'] = balance
How would one go about this? If I were to replace the dicts with Transaction objects having date and amount properties, would it then be possible?
 
     
     
    