nodes: 0, module; 1, function_definition; 2, function_name:sort_by; 3, parameters; 4, block; 5, identifier:function; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""
      Sorts an incoming sequence by using the given `function` as key.
  
      >>> range(10) > sort_by(-X)
      [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
  
      Supports automatic data-structure creation::
  
          users > sort_by([X.last_name, X.first_name])
  
      There is also a shortcut for ``sort_by(X)`` called ``sort``:
  
      >>> [4, 5, 8, -3, 0] > sort
      [-3, 0, 4, 5, 8]
  
      And (as of ``0.2.3``) a shortcut for reversing the sort:
  
      >>> 'asdfaSfa' > sort_by(X.lower()).descending
      ['s', 'S', 'f', 'f', 'd', 'a', 'a', 'a']
      """; 11, assignment; 12, assignment; 13, identifier:f; 14, identifier:f; 15, call; 16, attribute; 17, dictionary; 18, identifier:partial; 19, argument_list; 20, identifier:f; 21, identifier:attrs; 22, pair; 23, identifier:sorted; 24, keyword_argument; 25, string; 26, call; 27, identifier:key; 28, identifier:function; 29, string_content:descending; 30, identifier:_descending_sort_by; 31, argument_list; 32, identifier:function
code: def sort_by(function):
      """
      Sorts an incoming sequence by using the given `function` as key.
  
      >>> range(10) > sort_by(-X)
      [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
  
      Supports automatic data-structure creation::
  
          users > sort_by([X.last_name, X.first_name])
  
      There is also a shortcut for ``sort_by(X)`` called ``sort``:
  
      >>> [4, 5, 8, -3, 0] > sort
      [-3, 0, 4, 5, 8]
  
      And (as of ``0.2.3``) a shortcut for reversing the sort:
  
      >>> 'asdfaSfa' > sort_by(X.lower()).descending
      ['s', 'S', 'f', 'f', 'd', 'a', 'a', 'a']
      """
      f = partial(sorted, key=function)
      f.attrs = {'descending': _descending_sort_by(function)}
      return f