<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _sort_modules(mods):
 """ Always sort `index` or `README` as first filename in list. """


    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))