def _sort_modules(mods):
    def compare(x, y):
        x = x[1]
        y = y[1]
        if x == y:
            return 0
        if y.stem == "__init__.py":
            return 1
        if x.stem == "__init__.py" or x < y:
            return -1
        return 1
    return sorted(mods, key=cmp_to_key(compare))