nodes: 0, module; 1, function_definition; 2, function_name:get_sort_field; 3, parameters; 4, block; 5, identifier:request; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, comment:"""
      Retrieve field used for sorting a queryset
  
      :param request: HTTP request
      :return: the sorted field name, prefixed with "-" if ordering is descending
      """; 13, assignment; 14, assignment; 15, assignment; 16, assignment; 17, identifier:result_field; 18, identifier:sort_direction; 19, call; 20, identifier:field_name; 21, conditional_expression:(request.GET.get("sort") or "") if sort_direction else ""; 22, identifier:sort_sign; 23, conditional_expression:"-" if sort_direction == "desc" else ""; 24, identifier:result_field; 25, call; 26, attribute; 27, argument_list; 28, parenthesized_expression; 29, identifier:sort_direction; 30, string:""; 31, string:"-"; 32, comparison_operator:sort_direction == "desc"; 33, string:""; 34, attribute; 35, argument_list; 36, attribute; 37, identifier:get; 38, string:"dir"; 39, boolean_operator; 40, identifier:sort_direction; 41, string:"desc"; 42, string:"{sign}{field}"; 43, identifier:format; 44, keyword_argument; 45, keyword_argument; 46, identifier:request; 47, identifier:GET; 48, call; 49, string:""; 50, identifier:sign; 51, identifier:sort_sign; 52, identifier:field; 53, identifier:field_name; 54, attribute; 55, argument_list; 56, attribute; 57, identifier:get; 58, string:"sort"; 59, identifier:request; 60, identifier:GET
code: def get_sort_field(request):
      """
      Retrieve field used for sorting a queryset
  
      :param request: HTTP request
      :return: the sorted field name, prefixed with "-" if ordering is descending
      """
      sort_direction = request.GET.get("dir")
      field_name = (request.GET.get("sort") or "") if sort_direction else ""
      sort_sign = "-" if sort_direction == "desc" else ""
      result_field = "{sign}{field}".format(sign=sort_sign, field=field_name)
      return result_field