def get_sort_field(model=None, sort_field='sort', order_name='asc'):
    """
    Get sort column info according request, the data format just likes:

        ?sort=fieldA.asc&sort=fieldB.desc

        or:

        ?sort=fieldA&sort=fieldB&order=asc&order=desc

    default order is 'asc'. `field` can be just like `model.field`
    :param model: default model, if no model existed in field
    :param sort_field: sort field name in request
    :param order_name: order field name in request, the order direction can be
        set in field, just like `model.field.asc` or `field.asc`, etc.
    :return:
    """
    from uliweb import request
    
    if request.values.getlist('sort'):
        sort_fields = request.values.getlist('sort')
        order_by = []
        orders = request.values.getlist('order')
        for i, f in enumerate(sort_fields):
            _order = 'asc'
            if not orders:
                if f.endswith('.asc') or f.endswith('.desc'):
                    f, _order = f.rsplit('.', 1)
                else:
                    continue
            field = get_column(f, model)
            if field is not None:
                if orders:
                    _order = orders[i]
                if _order == 'asc':
                    order_by.append(field)
                else:
                    order_by.append(field.desc())
    else:
        order_by = None
        
    return order_by
def get_sort_field ( model = None , sort_field = 'sort' , order_name = 'asc' ) : from uliweb import request if request . values . getlist ( 'sort' ) : sort_fields = request . values . getlist ( 'sort' ) order_by = [ ] orders = request . values . getlist ( 'order' ) for i , f in enumerate ( sort_fields ) : _order = 'asc' if not orders : if f . endswith ( '.asc' ) or f . endswith ( '.desc' ) : f , _order = f . rsplit ( '.' , 1 ) else : continue field = get_column ( f , model ) if field is not None : if orders : _order = orders [ i ] if _order == 'asc' : order_by . append ( field ) else : order_by . append ( field . desc ( ) ) else : order_by = None return order_by
Get sort column info according request, the data format just likes:

        ?sort=fieldA.asc&sort=fieldB.desc

        or:

        ?sort=fieldA&sort=fieldB&order=asc&order=desc

    default order is 'asc'. `field` can be just like `model.field`
    :param model: default model, if no model existed in field
    :param sort_field: sort field name in request
    :param order_name: order field name in request, the order direction can be
        set in field, just like `model.field.asc` or `field.asc`, etc.
    :return: