title: TypeError: if no direction is specified, key_or_list must be an instance of list
body: <p>I am running into error at line <code>collection.find({}).sort({"_id":-1})</code>,how do I sort a collection of documents in mongodb?</p>
  
  <pre><code>count = 1
  cursor = collection.find({}).sort({"_id":-1})
  for document in cursor:
      if count !=100:
          logger.info('COUNT %s'%count)
          logger.info('document %s'%document)
      else:
          logger.info('Exiting...')
          sys.exit(0)
  </code></pre>
  
  <p>Error:-</p>
  
  <pre><code>Traceback (most recent call last):
    File "ibait_data_integrity.py", line 79, in &lt;module&gt;
      main()
    File "ibait_data_integrity.py", line 66, in main
      cursor = collection.find({}).sort({"_id":-1})
    File "/Library/Python/2.7/site-packages/pymongo/cursor.py", line 703, in sort
      keys = helpers._index_list(key_or_list, direction)
    File "/Library/Python/2.7/site-packages/pymongo/helpers.py", line 52, in _index_list
      raise TypeError("if no direction is specified, "
  TypeError: if no direction is specified, key_or_list must be an instance of list
  </code></pre>