nodes: 0, module; 1, function_definition; 2, function_name:_ranges_key; 3, parameters; 4, block; 5, identifier:r; 6, identifier:delta_indices; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:"""Sorting key for ranges.
  
      When used with ``reverse=True``, this can be used to sort index ranges into
      the order we would prefer to eliminate them by evaluating KroneckerDeltas:
      First, eliminate primed indices, then indices names higher in the alphabet.
      """; 11, assignment; 12, comparison_operator:idx in delta_indices; 13, block; 14, else_clause; 15, identifier:idx; 16, attribute; 17, identifier:idx; 18, identifier:delta_indices; 19, return_statement; 20, comment:# ranges that are not in delta_indices should remain in the original; 21, comment:# order; 22, block; 23, identifier:r; 24, identifier:index_symbol; 25, tuple; 26, return_statement; 27, attribute; 28, attribute; 29, tuple; 30, attribute; 31, identifier:primed; 32, attribute; 33, identifier:name; 34, integer:0; 35, string; 36, identifier:r; 37, identifier:index_symbol; 38, identifier:r; 39, identifier:index_symbol; 40, string_content:
code: def _ranges_key(r, delta_indices):
      """Sorting key for ranges.
  
      When used with ``reverse=True``, this can be used to sort index ranges into
      the order we would prefer to eliminate them by evaluating KroneckerDeltas:
      First, eliminate primed indices, then indices names higher in the alphabet.
      """
      idx = r.index_symbol
      if idx in delta_indices:
          return (r.index_symbol.primed, r.index_symbol.name)
      else:
          # ranges that are not in delta_indices should remain in the original
          # order
          return (0, ' ')