nodes: 0, module; 1, function_definition; 2, function_name:get_ordering; 3, parameters; 4, block; 5, identifier:self; 6, identifier:request; 7, identifier:queryset; 8, identifier:view; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, comment:# No sorting was included; 13, return_statement; 14, comment:"""Return an ordering for a given request.
  
          DRF expects a comma separated list, while DREST expects an array.
          This method overwrites the DRF default so it can parse the array.
          """; 15, assignment; 16, identifier:params; 17, block; 18, call; 19, identifier:params; 20, call; 21, expression_statement; 22, expression_statement; 23, comment:# if any of the sort fields are invalid, throw an error.; 24, comment:# else return the ordering; 25, if_statement; 26, attribute; 27, argument_list; 28, attribute; 29, argument_list; 30, assignment; 31, assignment; 32, identifier:invalid_ordering; 33, block; 34, else_clause; 35, identifier:self; 36, identifier:get_default_ordering; 37, identifier:view; 38, identifier:view; 39, identifier:get_request_feature; 40, attribute; 41, identifier:fields; 42, list_comprehension; 43, pattern_list; 44, call; 45, raise_statement; 46, block; 47, identifier:view; 48, identifier:SORT; 49, call; 50, for_in_clause; 51, identifier:valid_ordering; 52, identifier:invalid_ordering; 53, attribute; 54, argument_list; 55, call; 56, return_statement; 57, attribute; 58, argument_list; 59, identifier:param; 60, identifier:params; 61, identifier:self; 62, identifier:remove_invalid_fields; 63, identifier:queryset; 64, identifier:fields; 65, identifier:view; 66, identifier:ValidationError; 67, argument_list; 68, identifier:valid_ordering; 69, identifier:param; 70, identifier:strip; 71, binary_operator:"Invalid filter field: %s" % invalid_ordering; 72, string:"Invalid filter field: %s"; 73, identifier:invalid_ordering
code: def get_ordering(self, request, queryset, view):
          """Return an ordering for a given request.
  
          DRF expects a comma separated list, while DREST expects an array.
          This method overwrites the DRF default so it can parse the array.
          """
          params = view.get_request_feature(view.SORT)
          if params:
              fields = [param.strip() for param in params]
              valid_ordering, invalid_ordering = self.remove_invalid_fields(
                  queryset, fields, view
              )
  
              # if any of the sort fields are invalid, throw an error.
              # else return the ordering
              if invalid_ordering:
                  raise ValidationError(
                      "Invalid filter field: %s" % invalid_ordering
                  )
              else:
                  return valid_ordering
  
          # No sorting was included
          return self.get_default_ordering(view)