def aggregate_by_key(records):
    totals = {}
    for record in records:
        if not isinstance(record, dict):
            continue
        key = record.get('key')
        value = record.get('value')
        if key is None:
            continue
        if isinstance(value, bool) or not isinstance(value, (int, float)):
            continue
        totals[key] = totals.get(key, 0) + value
    return dict(sorted(totals.items()))
