from sqlalchemy.types import Integer
from app import app, db
from models import Target
data = Target.query.order_by(Target.product['salesrank'].cast(Integer))
Using JSON Type with Flask-sqlalchemy & Postgresql