I have a problem sorting Authors by
from sqlalchemy import func
page = request.args.get('page', 1, type=int)
pagination = Author.query.order_by(func.count(Author.likes)).paginate(page, per_page=app.config['AUTHORS_PER_PAGE'], error_out=False)
func.count and just order by
Author.likes, it's already a count.
func.count is for counting groups of things. Currently, you're grouping everything into one group and so you only get one item back.