parameters: (request, queryset, valid_sorts, default_sort=None)
return_statement: return queryset.order_by(sort), sort
docstring: For the given `queryset`,
          apply sort order based on request.GET['sort'].
docstring_summary: For the given `queryset`,
          apply sort order based on request.GET['sort'].
docstring_tokens: For the given queryset apply sort order based on request . GET [ sort ] .
function: def apply_sort_order(request, queryset, valid_sorts, default_sort=None):
      """
          For the given `queryset`,
          apply sort order based on request.GET['sort'].
      """
      if not default_sort:
          default_sort = valid_sorts[0]
      sort = request.GET.get('sort', default_sort)
      if sort not in valid_sorts:
          sort = default_sort
      return queryset.order_by(sort), sort
function_tokens: def apply_sort_order ( request , queryset , valid_sorts , default_sort = None ) : if not default_sort : default_sort = valid_sorts [ 0 ] sort = request . GET . get ( 'sort' , default_sort ) if sort not in valid_sorts : sort = default_sort return queryset . order_by ( sort ) , sort