This is my feeble attempt at the problem - but it does the job: def index(): add_submenu() headers = {'email.id': A('Id', _href=URL(vars=dict(orderby='id'))), 'email.email': A('Email address', _href=URL(vars=dict(orderby='email'))), 'email.active':A('Active', _href=URL(vars=dict(orderby='active'))), 'email.expires':A('Expires', _href=URL(vars=dict(orderby='expires'))), 'email.change_user':A('Changed by', _href=URL(vars=dict(orderby='change_user'))), 'email.change_date':A('Changed on', _href=URL(vars=dict(orderby='change_date'))), } if 'email_orderby' not in session: session.email_orderby = ['asc', 'email'] if 'orderby' in request.vars: if session.email_orderby[1] == request.vars.orderby: if session.email_orderby[0] == 'asc': session.email_orderby[0] = 'desc' else: session.email_orderby[0] = 'asc' else: session.email_orderby = ['asc', request.vars.orderby] key = db.email[session.email_orderby[1]] if session.email_orderby[0] == 'asc': emails = crud.select(db.email, headers=headers, orderby=key) else: emails = crud.select(db.email, headers=headers, orderby= ~key) return dict(emails=emails)
I don't like it - it looks ugly. Who can make it look more elegant? Best regards, Andreas balo...@gmail.com