title: How to sort the table according to the total_score column in SQLAlchemy and display?
body: <p>I want to display all the candidates' data according to the scores(in descending order) in my flask application. I have used SQLAlchemy.
  Here is my table:</p>
  <pre><code>class database(db.Model):
      id=db.Column('user_id',db.Integer, primary_key=True)
      rank=db.Column(db.Integer)
      name = db.Column(db.String(20))
      text=db.Column(db.String(1000))
      personality_score=db.Column(db.Integer)
      skills_score=db.Column(db.Integer)
      experience_score=db.Column(db.Integer)
      total_score=db.Column(db.Integer)
  </code></pre>
  <p>Here is the method I tried to fill the rank column and display the table. I NEED HELP IN THIS SECTION.
  When any candidate enters the data, then he should get adjusted according to his total score in the table and in the right column rank-wise.</p>
  <pre><code>candidates = database.query.order_by(database.total_score._desc()).all() #fetch them all in one query
              for (rank, database) in enumerate(candidates):
                  database.rank = rank + 1 #plus 1 cause enumerate starts from zero
              data=database(rank,request.form['name'],request.form['message'],    personality_score,skills_score, experience_score,candidate_total)
              db.session.add(data)
              db.session.commit()
  </code></pre>
  <p>Code for displaying it:</p>
  <pre><code>@app.route('/admin')
  def admin():
      return render_template('admin.html',database=database.query.all())
  </code></pre>