from typing import OrderedDict


def names_to_abbreviations(reporters):
    """Build a dict mapping names to their variations

    Something like:

        {
            "Atlantic Reporter": ['A.', 'A.2d'],
        }

    Note that the abbreviations are sorted by start date.
    """
    names = {}
    for reporter_key, data_list in reporters.items():
        for data in data_list:
            abbrevs = data["editions"].keys()
            # Sort abbreviations by start date of the edition
            sort_func = lambda x: str(data["editions"][x]["start"]) + x
            abbrevs = sorted(abbrevs, key=sort_func)
            names[data["name"]] = abbrevs
    sorted_names = OrderedDict(sorted(names.items(), key=lambda t: t[0]))
    return sorted_names