class_docstr: Superclass for Product and Sum.
  
  See Also
  ========
  
  sympy.concrete.expr_with_limits.ExprWithLimits
  sympy.concrete.products.Product
  sympy.concrete.summations.Sum
class_docstr_tok: ["Superclass","for","Product","and","Sum",".","See","Also","========","sympy.concrete.expr_with_limits.ExprWithLimits","sympy.concrete.products.Product","sympy.concrete.summations.Sum"]
docstr: Reorder limits in a expression containing a Sum or a Product.
  
  Explanation
  ===========
  
  ``expr.reorder(*arg)`` reorders the limits in the expression ``expr``
  according to the list of tuples given by ``arg``. These tuples can
  contain numerical indices or index variable names or involve both.
  
  Examples
  ========
  
  >>> from sympy import Sum, Product
  >>> from sympy.abc import x, y, z, a, b, c, d, e, f
  
  >>> Sum(x*y, (x, a, b), (y, c, d)).reorder((x, y))
  Sum(x*y, (y, c, d), (x, a, b))
  
  >>> Sum(x*y*z, (x, a, b), (y, c, d), (z, e, f)).reorder((x, y), (x, z), (y, z))
  Sum(x*y*z, (z, e, f), (y, c, d), (x, a, b))
  
  >>> P = Product(x*y*z, (x, a, b), (y, c, d), (z, e, f))
  >>> P.reorder((x, y), (x, z), (y, z))
  Product(x*y*z, (z, e, f), (y, c, d), (x, a, b))
  
  We can also select the index variables by counting them, starting
  with the inner-most one:
  
  >>> Sum(x**2, (x, a, b), (x, c, d)).reorder((0, 1))
  Sum(x**2, (x, c, d), (x, a, b))
  
  And of course we can mix both schemes:
  
  >>> Sum(x*y, (x, a, b), (y, c, d)).reorder((y, x))
  Sum(x*y, (y, c, d), (x, a, b))
  >>> Sum(x*y, (x, a, b), (y, c, d)).reorder((y, 0))
  Sum(x*y, (y, c, d), (x, a, b))
  
  See Also
  ========
  
  reorder_limit, index, sympy.concrete.summations.Sum.reverse_order,
  sympy.concrete.products.Product.reverse_order
docstr_tok: ["Reorder","limits","in","a","expression","containing","a","Sum","or","a","Product",".","Explanation","===========","``","expr.reorder","(","*","arg",")","``","reorders","the","limits","in","the","expression","``","expr","``","according","to","the","list","of","tuples","given","by","``","arg","``",".","These","tuples","can","contain","numerical","indices","or","index","variable","names","or","involve","both",".","Examples","========",">",">",">","from","sympy","import","Sum",",","Product",">",">",">","from","sympy.abc","import","x",",","y",",","z",",","a",",","b",",","c",",","d",",","e",",","f",">",">",">","Sum","(","x","*","y",",","(","x",",","a",",","b",")",",","(","y",",","c",",","d",")",")",".reorder","(","(","x",",","y",")",")","Sum","(","x","*","y",",","(","y",",","c",",","d",")",",","(","x",",","a",",","b",")",")",">",">",">","Sum","(","x","*","y","*","z",",","(","x",",","a",",","b",")",",","(","y",",","c",",","d",")",",","(","z",",","e",",","f",")",")",".reorder","(","(","x",",","y",")",",","(","x",",","z",")",",","(","y",",","z",")",")","Sum","(","x","*","y","*","z",",","(","z",",","e",",","f",")",",","(","y",",","c",",","d",")",",","(","x",",","a",",","b",")",")",">",">",">","P","=","Product","(","x","*","y","*","z",",","(","x",",","a",",","b",")",",","(","y",",","c",",","d",")",",","(","z",",","e",",","f",")",")",">",">",">","P.reorder","(","(","x",",","y",")",",","(","x",",","z",")",",","(","y",",","z",")",")","Product","(","x","*","y","*","z",",","(","z",",","e",",","f",")",",","(","y",",","c",",","d",")",",","(","x",",","a",",","b",")",")","We","can","also","select","the","index","variables","by","counting","them",",","starting","with","the","inner-most","one",":",">",">",">","Sum","(","x","*","*","2",",","(","x",",","a",",","b",")",",","(","x",",","c",",","d",")",")",".reorder","(","(","0",",","1",")",")","Sum","(","x","*","*","2",",","(","x",",","c",",","d",")",",","(","x",",","a",",","b",")",")","And","of","course","we","can","mix","both","schemes",":",">",">",">","Sum","(","x","*","y",",","(","x",",","a",",","b",")",",","(","y",",","c",",","d",")",")",".reorder","(","(","y",",","x",")",")","Sum","(","x","*","y",",","(","y",",","c",",","d",")",",","(","x",",","a",",","b",")",")",">",">",">","Sum","(","x","*","y",",","(","x",",","a",",","b",")",",","(","y",",","c",",","d",")",")",".reorder","(","(","y",",","0",")",")","Sum","(","x","*","y",",","(","y",",","c",",","d",")",",","(","x",",","a",",","b",")",")","See","Also","========","reorder_limit",",","index",",","sympy.concrete.summations.Sum.reverse_order",",","sympy.concrete.products.Product.reverse_order"]
code: def reorder(expr, *arg):
      """
      Reorder limits in a expression containing a Sum or a Product.
  
      Explanation
      ===========
  
      ``expr.reorder(*arg)`` reorders the limits in the expression ``expr``
      according to the list of tuples given by ``arg``. These tuples can
      contain numerical indices or index variable names or involve both.
  
      Examples
      ========
  
      >>> from sympy import Sum, Product
      >>> from sympy.abc import x, y, z, a, b, c, d, e, f
  
      >>> Sum(x*y, (x, a, b), (y, c, d)).reorder((x, y))
      Sum(x*y, (y, c, d), (x, a, b))
  
      >>> Sum(x*y*z, (x, a, b), (y, c, d), (z, e, f)).reorder((x, y), (x, z), (y, z))
      Sum(x*y*z, (z, e, f), (y, c, d), (x, a, b))
  
      >>> P = Product(x*y*z, (x, a, b), (y, c, d), (z, e, f))
      >>> P.reorder((x, y), (x, z), (y, z))
      Product(x*y*z, (z, e, f), (y, c, d), (x, a, b))
  
      We can also select the index variables by counting them, starting
      with the inner-most one:
  
      >>> Sum(x**2, (x, a, b), (x, c, d)).reorder((0, 1))
      Sum(x**2, (x, c, d), (x, a, b))
  
      And of course we can mix both schemes:
  
      >>> Sum(x*y, (x, a, b), (y, c, d)).reorder((y, x))
      Sum(x*y, (y, c, d), (x, a, b))
      >>> Sum(x*y, (x, a, b), (y, c, d)).reorder((y, 0))
      Sum(x*y, (y, c, d), (x, a, b))
  
      See Also
      ========
  
      reorder_limit, index, sympy.concrete.summations.Sum.reverse_order,
      sympy.concrete.products.Product.reverse_order
      """
      new_expr = expr
  
      for r in arg:
          if len(r) != 2:
              raise ValueError(r, "Invalid number of arguments")
  
          index1 = r[0]
          index2 = r[1]
  
          if not isinstance(r[0], int):
              index1 = expr.index(r[0])
          if not isinstance(r[1], int):
              index2 = expr.index(r[1])
  
          new_expr = new_expr.reorder_limit(index1, index2)
  
      return new_expr
  
file_path: sympy/sympy/concrete/expr_with_intlimits.py
imports: from sympy.concrete.expr_with_limits import ExprWithLimits
  from sympy.core.singleton import S
  from sympy.core.relational import Eq
label_desc: Use image node_id 3 for calling the ExprWithIntLimits obj's underlying member method code with example usage: obj.reorder(expr) and returns: new_expr