code: def _cycle_permute(l):
      """Cyclic permutations based on canonical ordering
  
      Explanation
      ===========
  
      This method does the sort based ascii values while
      a better approach would be to used lexicographic sort.
  
      TODO: Handle condition such as symbols have subscripts/superscripts
      in case of lexicographic sort
  
      """
  
      if len(l) == 1:
          return l
  
      min_item = min(l, key=default_sort_key)
      indices = [i for i, x in enumerate(l) if x == min_item]
  
      le = list(l)
      le.extend(l)  # duplicate and extend string for easy processing
  
      # adding the first min_item index back for easier looping
      indices.append(len(l) + indices[0])
  
      # create sublist of items with first item as min_item and last_item
      # in each of the sublist is item just before the next occurrence of
      # minitem in the cycle formed.
      sublist = [
          [le[indices[i] : indices[i + 1]]]
          for i in range(len(indices) - 1)
      ]
  
      # we do comparison of strings by comparing elements
      # in each sublist
      idx = sublist.index(min(sublist))
      ordered_l = le[indices[idx] : indices[idx] + len(l)]
  
      return ordered_l
  
file_path: sympy/sympy/physics/quantum/trace.py
imports: from sympy.core.add import Add
  from sympy.core.containers import Tuple
  from sympy.core.expr import Expr
  from sympy.core.mul import Mul
  from sympy.core.power import Pow
  from sympy.core.sorting import default_sort_key
  from sympy.core.sympify import sympify
  from sympy.matrices import Matrix
label_desc: Use image node_id 2 for calling a global function with example usage: _cycle_permute(l) and returns: ordered_l, l