def sort_models_topologically(models):
        models = set(models)
        seen = set()
        ordering = []
        def dfs(model):
            if model in models and model not in seen:
                seen.add(model)
                for foreign_key in model._meta.reverse_rel.values():
                    dfs(foreign_key.model_class)
                ordering.append(model)  # parent will follow descendants
        # Order models by name and table initially to guarantee total ordering.
        names = lambda m: (m._meta.name, m._meta.db_table)
        for m in sorted(models, key=names, reverse=True):
            dfs(m)
        return list(reversed(ordering))
Internal routine to get nobody's uid
dataset/ETHPy150Open coleifer/peewee/peewee.py/sort_models_topologically--crossover with--dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/CGIHTTPServer.py/nobody_uid