title: using Levenshtein Distance to sort search query in sqlalchemy?
body: <p>I've been trying to get Sqlalchemy to use a function ( Levenshtein Distance ) to order the results of a query , I've tried some of the ideas here and there , but none use a parameter that is not in the Sqlalchemy model it self , here is what i am trying to do : </p>
  
  <pre><code>    communs=baladiya.query.filter_by(wilaya=wilaya).filter(baladiya.name.like('%{}%'.format(name))).order_by(jf.Levenshtein_Distance(searchstring,baladiya.name)).paginate(per_page=4,page=page)
  </code></pre>
  
  <p>i am using this method to keep the app well structured and can use paginate object , 
  if this is not possible at all  , is there a way to create an empty query , and then keep appending using my own sorting .</p>
  
  <p>this is the baladiya model : </p>
  
  <pre><code>class baladiya(db.Model):
  id = db.Column(db.Integer , primary_key=True)
  name = db.Column(db.String(1000),unique=False , nullable=False)
  postalcode = db.Column(db.String(10),unique=True, nullable=False)
  posX = db.Column(db.String(20), nullable=True, default='16000')
  posY = db.Column(db.String(20), nullable=True, default='16000')
  wilaya= db.Column(db.Integer,unique=False, nullable=False)
  </code></pre>