nodes: 0, module; 1, function_definition; 2, function_name:build_sort; 3, parameters; 4, block; 5, identifier:self; 6, dictionary_splat_pattern; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:kwargs; 13, string; 14, assignment; 15, assignment; 16, identifier:order; 17, block; 18, identifier:sort; 19, string_content:Break url parameters and turn into sort arguments; 20, identifier:sort; 21, list; 22, identifier:order; 23, call; 24, if_statement; 25, if_statement; 26, attribute; 27, argument_list; 28, comparison_operator:type(order) is list; 29, block; 30, comparison_operator:order[:1] == '-'; 31, block; 32, else_clause; 33, identifier:kwargs; 34, identifier:get; 35, string; 36, None; 37, call; 38, identifier:list; 39, expression_statement; 40, subscript; 41, string; 42, expression_statement; 43, block; 44, string_content:order_by; 45, identifier:type; 46, argument_list; 47, assignment; 48, identifier:order; 49, slice; 50, string_content:-; 51, call; 52, expression_statement; 53, identifier:order; 54, identifier:order; 55, subscript; 56, integer:1; 57, attribute; 58, argument_list; 59, call; 60, identifier:order; 61, integer:0; 62, identifier:sort; 63, identifier:append; 64, tuple; 65, attribute; 66, argument_list; 67, subscript; 68, unary_operator; 69, identifier:sort; 70, identifier:append; 71, tuple; 72, identifier:order; 73, slice; 74, integer:1; 75, identifier:order; 76, integer:1; 77, integer:1
code: def build_sort(self, **kwargs):
          ''' Break url parameters and turn into sort arguments '''
          sort = []
          order = kwargs.get('order_by', None)
          if order:
              if type(order) is list:
                  order = order[0]
              if order[:1] == '-':
                  sort.append((order[1:], -1))
              else:
                  sort.append((order, 1))
          return sort