import itertools


def class_dict_from_index_dict(idx_dct):
    """ Obtain a class dictionary from a class index dictionary.

        :param idx_dct: A dictionary mapping atom keys to class indices.
        :type idx_dct: dict
        :returns: A dictionary mapping class indices onto the full set of keys
            for that class, as a sorted tuple.
        :rtype: dict[int: tuple]
    """
    keys = sorted(idx_dct.keys())
    clas = sorted(keys, key=idx_dct.__getitem__)
    cla_dct = {i: tuple(c)
               for i, c in itertools.groupby(clas, key=idx_dct.__getitem__)}
    return cla_dct