def aggregate_by_key(records):
    agg = {}
    for record in records:
        if 'key' in record and 'value' in record:
            key = record['key']
            value = record['value']
            if key in agg:
                agg[key] += value
            else:
                agg[key] = value
    return dict(sorted(agg.items()))
