nodes: 0, module; 1, function_definition; 2, function_name:index_natsorted; 3, parameters; 4, block; 5, identifier:seq; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, comment:# Pair the index and sequence together, then sort by element; 12, expression_statement; 13, expression_statement; 14, return_statement; 15, identifier:key; 16, None; 17, identifier:reverse; 18, False; 19, identifier:alg; 20, attribute; 21, comment:"""
      Determine the list of the indexes used to sort the input sequence.
  
      Sorts a sequence naturally, but returns a list of sorted the
      indexes and not the sorted list itself. This list of indexes
      can be used to sort multiple lists by the sorted order of the
      given sequence.
  
      Parameters
      ----------
      seq : iterable
          The input to sort.
  
      key : callable, optional
          A key used to determine how to sort each element of the sequence.
          It is **not** applied recursively.
          It should accept a single argument and return a single value.
  
      reverse : {{True, False}}, optional
          Return the list in reversed sorted order. The default is
          `False`.
  
      alg : ns enum, optional
          This option is used to control which algorithm `natsort`
          uses when sorting. For details into these options, please see
          the :class:`ns` class documentation. The default is `ns.INT`.
  
      Returns
      -------
      out : tuple
          The ordered indexes of the input.
  
      See Also
      --------
      natsorted
      order_by_index
  
      Examples
      --------
  
      Use index_natsorted if you want to sort multiple lists by the
      sorted order of one list::
  
          >>> a = ['num3', 'num5', 'num2']
          >>> b = ['foo', 'bar', 'baz']
          >>> index = index_natsorted(a)
          >>> index
          [2, 0, 1]
          >>> # Sort both lists by the sort order of a
          >>> order_by_index(a, index)
          [{u}'num2', {u}'num3', {u}'num5']
          >>> order_by_index(b, index)
          [{u}'baz', {u}'foo', {u}'bar']
  
      """; 22, comparison_operator:key is None; 23, block; 24, else_clause; 25, assignment; 26, call; 27, list_comprehension; 28, identifier:ns; 29, identifier:DEFAULT; 30, identifier:key; 31, None; 32, expression_statement; 33, block; 34, identifier:index_seq_pair; 35, list_comprehension; 36, attribute; 37, argument_list; 38, identifier:x; 39, for_in_clause; 40, assignment; 41, function_definition; 42, list; 43, for_in_clause; 44, identifier:index_seq_pair; 45, identifier:sort; 46, keyword_argument; 47, keyword_argument; 48, pattern_list; 49, identifier:index_seq_pair; 50, identifier:newkey; 51, call; 52, function_name:newkey; 53, parameters; 54, block; 55, identifier:x; 56, identifier:y; 57, pattern_list; 58, call; 59, identifier:reverse; 60, identifier:reverse; 61, identifier:key; 62, call; 63, identifier:x; 64, identifier:_; 65, identifier:itemgetter; 66, argument_list; 67, identifier:x; 68, return_statement; 69, identifier:x; 70, identifier:y; 71, identifier:enumerate; 72, argument_list; 73, identifier:natsort_keygen; 74, argument_list; 75, integer:1; 76, call; 77, identifier:seq; 78, identifier:newkey; 79, identifier:alg; 80, identifier:key; 81, argument_list; 82, call; 83, call; 84, argument_list; 85, identifier:itemgetter; 86, argument_list; 87, identifier:x; 88, integer:1
code: def index_natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
      """
      Determine the list of the indexes used to sort the input sequence.
  
      Sorts a sequence naturally, but returns a list of sorted the
      indexes and not the sorted list itself. This list of indexes
      can be used to sort multiple lists by the sorted order of the
      given sequence.
  
      Parameters
      ----------
      seq : iterable
          The input to sort.
  
      key : callable, optional
          A key used to determine how to sort each element of the sequence.
          It is **not** applied recursively.
          It should accept a single argument and return a single value.
  
      reverse : {{True, False}}, optional
          Return the list in reversed sorted order. The default is
          `False`.
  
      alg : ns enum, optional
          This option is used to control which algorithm `natsort`
          uses when sorting. For details into these options, please see
          the :class:`ns` class documentation. The default is `ns.INT`.
  
      Returns
      -------
      out : tuple
          The ordered indexes of the input.
  
      See Also
      --------
      natsorted
      order_by_index
  
      Examples
      --------
  
      Use index_natsorted if you want to sort multiple lists by the
      sorted order of one list::
  
          >>> a = ['num3', 'num5', 'num2']
          >>> b = ['foo', 'bar', 'baz']
          >>> index = index_natsorted(a)
          >>> index
          [2, 0, 1]
          >>> # Sort both lists by the sort order of a
          >>> order_by_index(a, index)
          [{u}'num2', {u}'num3', {u}'num5']
          >>> order_by_index(b, index)
          [{u}'baz', {u}'foo', {u}'bar']
  
      """
      if key is None:
          newkey = itemgetter(1)
      else:
  
          def newkey(x):
              return key(itemgetter(1)(x))
  
      # Pair the index and sequence together, then sort by element
      index_seq_pair = [[x, y] for x, y in enumerate(seq)]
      index_seq_pair.sort(reverse=reverse, key=natsort_keygen(newkey, alg))
      return [x for x, _ in index_seq_pair]