s = select([literal_column('key', Integer), literal_column('sort_order',
    Integer)]).select_from(text('({}) AS helper'.format(text(q_subq)))).alias(
    'helper')
Ordering and pagination in SQL-alchemy using non-sql ranking