def reverseDictDict(d):
    """reverses the order of keys in a dict of dicts"""
    assert isinstance(next(iter(d.values())), dict
        ), 'reverseDictDict not given a dictionary of dictionaries'
    revDict = dict()
    for key1, subd in d.items():
        for key2, value in subd.items():
            if not key2 in revDict:
                revDict[key2] = dict()
            revDict[key2][key1] = value
    return revDict
