'Spend the oldest buckets first.'

def choose_buckets(self, buckets, sufficient_funds, penalty_func):

    adj_height = (lambda height: (99999999 if (height <= 0) else height))
    buckets.sort(key=(lambda b: max((adj_height(coin['height']) for coin in b.coins))))
    selected = []
    for bucket in buckets:
        selected.append(bucket)
        if sufficient_funds(selected):
            return strip_unneeded(selected, sufficient_funds)
    else:
        raise NotEnoughFunds()
