def compute_direct_sort_map(lang):
    """ Return a map from each sort s to a list of the objects that have s as their direct sort
     (i.e. ignoring parent sorts). """
    res = {s: [] for s in lang.sorts if not s.builtin}
    _ = [res[o.sort].append(o) for o in lang.constants()]
    return res