def clean_sort_param(request, date_sort='created'):
    """
    Handles empty and invalid values for sort and sort order.
    'created' by ascending is the default ordering.
    """
    sort = request.GET.get('sort', date_sort)
    order = request.GET.get('order', 'asc')

    if sort not in ('name', 'created', 'nomination'):
        sort = date_sort
    if order not in ('desc', 'asc'):
        order = 'asc'
    return sort, order