from typing import OrderedDict


def _ordered(data):
    """Sort a dictionary-like object by key."""
    if data is None:
        return None
    return OrderedDict(sorted(data.items(), key=lambda pair: pair[0]))