from typing import OrderedDict


def group_events_by_year(events):
    """
    Given a queryset of event objects,
    returns a sorted dictionary mapping years to event objects.
    """
    years = OrderedDict()

    for event in events:
        year = event.start_date.year
        if year not in years:
            years[year] = [event]
        else:
            years[year].append(event)
    return years