def update_balance(entries):
    """Sort entries by date and update balances."""
    entries.sort(key=lambda entry: entry.date)
    balance = 0
    for entry in entries:
        entry.balance = balance + entry.amount
        balance = entry.balance
