class_docstr: Symbolic operator representing the sum of operators.
  
  Args:
      *summands (tuple[~.operation.Operator]): a tuple of operators which will be summed together.
  
  Keyword Args:
      id (str or None): id for the sum operator. Default is None.
  
  .. note::
      Currently this operator can not be queued in a circuit as an operation, only measured terminally.
  
  .. note::
  
      This operator supports batched operands:
      >>> op = qml.sum(qml.RX(np.array([1, 2, 3]), wires=0), qml.PauliX(1))
      >>> op.matrix().shape
      (3, 4, 4)
  
      But it doesn't support batching of operators:
      >>> op = qml.sum(np.array([qml.RX(0.4, 0), qml.RZ(0.3, 0)]), qml.PauliZ(0))
      AttributeError: 'numpy.ndarray' object has no attribute 'wires'
  
  .. seealso:: :func:`~.ops.op_math.sum`
  
  **Example**
  
  >>> summed_op = Sum(qml.PauliX(0), qml.PauliZ(0))
  >>> summed_op
  PauliX(wires=[0]) + PauliZ(wires=[0])
  >>> qml.matrix(summed_op)
  array([[ 1,  1],
         [ 1, -1]])
  >>> summed_op.terms()
  ([1.0, 1.0], (PauliX(wires=[0]), PauliZ(wires=[0])))
  
  .. details::
      :title: Usage Details
  
      We can combine parameterized operators, and support sums between operators acting on
      different wires.
  
      >>> summed_op = Sum(qml.RZ(1.23, wires=0), qml.Identity(wires=1))
      >>> summed_op.matrix()
      array([[1.81677345-0.57695852j, 0.        +0.j        ,
              0.        +0.j        , 0.        +0.j        ],
             [0.        +0.j        , 1.81677345-0.57695852j,
              0.        +0.j        , 0.        +0.j        ],
             [0.        +0.j        , 0.        +0.j        ,
              1.81677345+0.57695852j, 0.        +0.j        ],
             [0.        +0.j        , 0.        +0.j        ,
              0.        +0.j        , 1.81677345+0.57695852j]])
  
      The Sum operation can also be measured inside a qnode as an observable.
      If the circuit is parameterized, then we can also differentiate through the
      sum observable.
  
      .. code-block:: python
  
          sum_op = Sum(qml.PauliX(0), qml.PauliZ(1))
          dev = qml.device("default.qubit", wires=2)
  
          @qml.qnode(dev, diff_method="best")
          def circuit(weights):
              qml.RX(weights[0], wires=0)
              qml.RY(weights[1], wires=1)
              qml.CNOT(wires=[0, 1])
              qml.RX(weights[2], wires=1)
              return qml.expval(sum_op)
  
      >>> weights = qnp.array([0.1, 0.2, 0.3], requires_grad=True)
      >>> qml.grad(circuit)(weights)
      array([-0.09347337, -0.18884787, -0.28818254])
docstr: Sort algorithm that sorts a list of sum summands by their wire indices.
  
  Args:
      op_list (List[.Operator]): list of operators to be sorted
      wire_map (dict): Dictionary containing the wire values as keys and its indexes as values.
          Defaults to None.
  
  Returns:
      List[.Operator]: sorted list of operators
docstr_tok: ["Sort","algorithm","that","sorts","a","list","of","sum","summands","by","their","wire","indices",".","Args",":","op_list","(","List","[",".Operator","]",")",":","list","of","operators","to","be","sorted","wire_map","(","dict",")",":","Dictionary","containing","the","wire","values","as","keys","and","its","indexes","as","values",".","Defaults","to","None",".","Returns",":","List","[",".Operator","]",":","sorted","list","of","operators"]
code: def _sort(cls, op_list, wire_map: dict = None) -> List[Operator]:
      """Sort algorithm that sorts a list of sum summands by their wire indices.
  
      Args:
          op_list (List[.Operator]): list of operators to be sorted
          wire_map (dict): Dictionary containing the wire values as keys and its indexes as values.
              Defaults to None.
  
      Returns:
          List[.Operator]: sorted list of operators
      """
  
      if isinstance(op_list, tuple):
          op_list = list(op_list)
  
      def _sort_key(op: Operator) -> tuple:
          """Sorting key used in the `sorted` python built-in function.
  
          Args:
              op (.Operator): Operator.
  
          Returns:
              Tuple[int, int, str]: Tuple containing the minimum wire value, the number of wires
                  and the string of the operator. This tuple is used to compare different operators
                  in the sorting algorithm.
          """
          wires = op.wires
          if wire_map is not None:
              wires = wires.map(wire_map)
          return np.min(wires), len(wires), str(op)
  
      return sorted(op_list, key=_sort_key)
  
imports: import itertools
  from copy import copy
  from typing import List
  import numpy
  import pennylane
  from pennylane import math
  from pennylane.operation import Operator
  from pennylane.ops.qubit import Hamiltonian
  from pennylane.queuing import QueuingManager
  from .composite import CompositeOp
label_desc: Use image node_id 12 for calling the Sum obj's underlying member method code with example usage: obj._sort(cls, op_list, wire_map) and returns: sorted, np,  len,  str