def single_sort_by(queryset, params):
    """
    Orders and returns the queryset using the GET parameters of a request
    The function takes care of checking if the "sort_by" key exists in the dict
    """
    sort_by = params.get('sort_by', None)
    if sort_by:
        ascending = params.get('ascending', False)
        if ascending != 'true':
            sort_by = '-' + sort_by
        queryset = queryset.order_by(sort_by)
    return queryset
