def url_replace_sort(req, new_sort):
    """
    Replace the old GET value of sort with a new value, or negate it if they are equal to sort the opposite way.
    
    Args:
        req: the http request
        new_sort: the sort value a user clicked on
        
    Returns:
        The updated url with the new sort value
    """
    dict_ = req.GET.copy()
    if 'sort' in dict_ and dict_['sort'] is not "":
        current_sort = dict_['sort']
        if current_sort == new_sort:
            dict_['sort'] = '-' + new_sort
        else:
            dict_['sort'] = new_sort
    else:
        dict_['sort'] = new_sort
    return dict_.urlencode()