A Casbah (MongoDB) ORDER BY 'find' query example

To create an order by query using the find method of the MongoDB Casbah driver (Scala), use the sort method, as shown in this example:

def findAll(): List[Url] = {
    // 1 == ascending, -1 == descending
    var urlsAsDbObjects = MongoFactory.urlsCollection.find().sort(MongoDBObject("created" -> -1))
    (for (u <- urlsAsDbObjects) yield convertDbObjectToUrl(u)).toList
}

As shown in the comment, specify 1 to order by the given field in ascending order, and specify -1 to order by the field in descending order.

I found some of this information at this Google Groups URL.