# How to order the results on a field?

  1. Construct the query using the collection's QueryBuilder class
  2. append the ordering to the query using asc or desc api.

For example:


 

val employeeQry = EmployeeQuery().designation.is("SSE")
val sseOrderedByAge = employeeQry.dob.asc.find

Note: Without any query criteria, results will be returned by the storage engine in natural order (aka in the order they are found). Result order may coincide with insertion order but this behaviour is not guaranteed and cannot be relied on (aside from capped collections).