nodes: 0, module; 1, function_definition; 2, function_name:then_by; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, if_statement; 10, expression_statement; 11, return_statement; 12, identifier:key_selector; 13, identifier:identity; 14, string; 15, call; 16, block; 17, not_operator; 18, block; 19, call; 20, identifier:self; 21, string_content:Introduce subsequent ordering to the sequence with an optional key.
  
          The returned sequence will be sorted in ascending order by the
          selected key.
  
          Note: This method uses deferred execution.
  
          Args:
              key_selector: A unary function the only positional argument to
                  which is the element value from which the key will be
                  selected.  The return value should be the key from that
                  element.
  
          Returns:
              An OrderedQueryable over the sorted items.
  
          Raises:
              ValueError: If the OrderedQueryable is closed().
              TypeError: If key_selector is not callable.; 22, attribute; 23, argument_list; 24, raise_statement; 25, call; 26, raise_statement; 27, attribute; 28, argument_list; 29, identifier:self; 30, identifier:closed; 31, call; 32, identifier:is_callable; 33, argument_list; 34, call; 35, attribute; 36, identifier:append; 37, tuple; 38, identifier:ValueError; 39, argument_list; 40, identifier:key_selector; 41, identifier:TypeError; 42, argument_list; 43, identifier:self; 44, identifier:_funcs; 45, unary_operator; 46, identifier:key_selector; 47, concatenated_string; 48, call; 49, integer:1; 50, string:"Attempt to call then_by() on a "; 51, string:"closed OrderedQueryable."; 52, attribute; 53, argument_list; 54, concatenated_string; 55, identifier:format; 56, keyword_argument; 57, string:"then_by() parameter key_selector={key_selector} "; 58, string:"is not callable"; 59, identifier:key_selector; 60, call; 61, identifier:repr; 62, argument_list; 63, identifier:key_selector
code: def then_by(self, key_selector=identity):
          '''Introduce subsequent ordering to the sequence with an optional key.
  
          The returned sequence will be sorted in ascending order by the
          selected key.
  
          Note: This method uses deferred execution.
  
          Args:
              key_selector: A unary function the only positional argument to
                  which is the element value from which the key will be
                  selected.  The return value should be the key from that
                  element.
  
          Returns:
              An OrderedQueryable over the sorted items.
  
          Raises:
              ValueError: If the OrderedQueryable is closed().
              TypeError: If key_selector is not callable.
          '''
          if self.closed():
              raise ValueError("Attempt to call then_by() on a "
                               "closed OrderedQueryable.")
  
          if not is_callable(key_selector):
              raise TypeError("then_by() parameter key_selector={key_selector} "
                      "is not callable".format(key_selector=repr(key_selector)))
  
          self._funcs.append((-1, key_selector))
          return self