title: Sqlalchemy order by calculated column
body: <p>I'm trying to build a select query using sqlalchemy, but I need to sort the results by a calculated value and I'm not sure how to do it.</p>
  
  <p>Basically, I have a 'start_time' and 'end_time' columns and I want to order the results based on start_time and then end_time but if end_time &lt; start_time I want to add 86400000 to it:</p>
  
  <pre><code>end_time + (86400000 if end_time &lt; start_time else 0)
  </code></pre>
  
  <p>I can't figure out how to do it. Is there any simple way to add a calculated property to my table class and have the query retrieve that property?</p>
  
  <p>I've tried using @property to create a getter for that calculated end_time but it didn't work.</p>