nodes: 0, module; 1, function_definition; 2, function_name:order_by_index; 3, parameters; 4, block; 5, identifier:seq; 6, identifier:index; 7, default_parameter; 8, expression_statement; 9, return_statement; 10, identifier:iter; 11, False; 12, comment:"""
      Order a given sequence by an index sequence.
  
      The output of `index_natsorted` is a
      sequence of integers (index) that correspond to how its input
      sequence **would** be sorted. The idea is that this index can
      be used to reorder multiple sequences by the sorted order of the
      first sequence. This function is a convenient wrapper to
      apply this ordering to a sequence.
  
      Parameters
      ----------
      seq : sequence
          The sequence to order.
  
      index : iterable
          The iterable that indicates how to order `seq`.
          It should be the same length as `seq` and consist
          of integers only.
  
      iter : {{True, False}}, optional
          If `True`, the ordered sequence is returned as a
          iterator; otherwise it is returned as a
          list. The default is `False`.
  
      Returns
      -------
      out : {{list, iterator}}
          The sequence ordered by `index`, as a `list` or as an
          iterator (depending on the value of `iter`).
  
      See Also
      --------
      index_natsorted
      index_humansorted
      index_realsorted
  
      Examples
      --------
  
      `order_by_index` is a convenience function that helps you apply
      the result of `index_natsorted`::
  
          >>> 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']
  
      """; 13, conditional_expression:(seq[i] for i in index) if iter else [seq[i] for i in index]; 14, generator_expression; 15, identifier:iter; 16, list_comprehension; 17, subscript; 18, for_in_clause; 19, subscript; 20, for_in_clause; 21, identifier:seq; 22, identifier:i; 23, identifier:i; 24, identifier:index; 25, identifier:seq; 26, identifier:i; 27, identifier:i; 28, identifier:index
code: def order_by_index(seq, index, iter=False):
      """
      Order a given sequence by an index sequence.
  
      The output of `index_natsorted` is a
      sequence of integers (index) that correspond to how its input
      sequence **would** be sorted. The idea is that this index can
      be used to reorder multiple sequences by the sorted order of the
      first sequence. This function is a convenient wrapper to
      apply this ordering to a sequence.
  
      Parameters
      ----------
      seq : sequence
          The sequence to order.
  
      index : iterable
          The iterable that indicates how to order `seq`.
          It should be the same length as `seq` and consist
          of integers only.
  
      iter : {{True, False}}, optional
          If `True`, the ordered sequence is returned as a
          iterator; otherwise it is returned as a
          list. The default is `False`.
  
      Returns
      -------
      out : {{list, iterator}}
          The sequence ordered by `index`, as a `list` or as an
          iterator (depending on the value of `iter`).
  
      See Also
      --------
      index_natsorted
      index_humansorted
      index_realsorted
  
      Examples
      --------
  
      `order_by_index` is a convenience function that helps you apply
      the result of `index_natsorted`::
  
          >>> 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']
  
      """
      return (seq[i] for i in index) if iter else [seq[i] for i in index]