title: best way to support dynamic column name and sort direction with peewee python
body: <p>So far i have something like this:</p>
  
  <pre><code>page_nr = request.query.page_nr
  how_many = request.query.how_many
  sort_direction = request.query.sort_direction
  sort_column = request.query.sort_column
  
  error_urls = Url.select().where((Url.crawl == crawl_id)) \
              .order_by(Url.total_time.desc()) \
              .paginate(int(page_nr), int(how_many)) \
              .dicts()
  </code></pre>
  
  <p>As you can see, i am not using sort_direction and sort_column.
  I tried the query below but it did not work.</p>
  
  <pre><code>error_urls = Url.select().where((Url.crawl == crawl_id) &amp; (Url.utype == 'internal')) \
              .order_by(SQL(sort_column).sort_direction()) \
              .paginate(int(page_nr), int(how_many)) \
              .dicts()
  
  (500, 'Internal Server Error', AttributeError("'SQL' object has no attribute 'sort_direction'",), 'Traceback (most recent call last):\n  File "/usr/local/lib/python3.5/dist-packages/bottle.py", line 862, in _handle\n    return route.call(**args)\n  File "/usr/local/lib/python3.5/dist-packages/bottle.py", line 1732, in wrapper\n    rv = callback(*a, **ka)\n  File "index.py", line 55, in _enable_cors\n    return fn(*args, **kwargs)\n  File "index.py", line 383, in get_performance\n    .order_by(SQL(sort_column).sort_direction()) \\\nAttributeError: \'SQL\' object has no attribute \'sort_direction\'\n')
  </code></pre>
  
  <p>Of course since sort_direction does not seem to be evaled.</p>
  
  <p>What is the best way to achieve dynamic sort_column and sort_direction using the peewee orm? Preferably without writing a raw query, If possible.</p>
  
  <p>Thanks</p>