def _sort_optimized(self, indices, expr):

        from sympy.tensor.indexed import Indexed

        if not indices:
            return []

        # determine optimized loop order by giving a score to each index
        # the index with the highest score are put in the innermost loop.
        score_table = {}
        for i in indices:
            score_table[i] = 0

        arrays = expr.atoms(Indexed)
        for arr in arrays:
            for p, ind in enumerate(arr.indices):
                try:
                    score_table[ind] += self._rate_index_position(p)
                except __HOLE__:
                    pass

        return sorted(indices, key=lambda x: score_table[x])
dataset/ETHPy150Open sympy/sympy/sympy/printing/codeprinter.py/CodePrinter._sort_optimized