nodes: 0, module; 1, function_definition; 2, function_name:SortBy; 3, parameters; 4, block; 5, list_splat_pattern; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, identifier:qs; 11, comment:"""Convert a list of Q objects into list of sort instructions"""; 12, assignment; 13, identifier:q; 14, identifier:qs; 15, block; 16, identifier:sort; 17, identifier:sort; 18, list; 19, if_statement; 20, call; 21, block; 22, else_clause; 23, attribute; 24, argument_list; 25, expression_statement; 26, block; 27, attribute; 28, identifier:endswith; 29, string; 30, call; 31, expression_statement; 32, identifier:q; 33, identifier:_path; 34, string_content:.desc; 35, attribute; 36, argument_list; 37, call; 38, identifier:sort; 39, identifier:append; 40, tuple; 41, attribute; 42, argument_list; 43, subscript; 44, identifier:DESCENDING; 45, identifier:sort; 46, identifier:append; 47, tuple; 48, attribute; 49, slice; 50, attribute; 51, identifier:ASCENDING; 52, identifier:q; 53, identifier:_path; 54, unary_operator; 55, identifier:q; 56, identifier:_path; 57, integer:5
code: def SortBy(*qs):
      """Convert a list of Q objects into list of sort instructions"""
  
      sort = []
      for q in qs:
          if q._path.endswith('.desc'):
              sort.append((q._path[:-5], DESCENDING))
          else:
              sort.append((q._path, ASCENDING))
      return sort