Support ordering of database entries

- Add method which orders the database query results before comparing with the expected rows.
Ordering is carried out on the database side of the query.

- Add test for ordered and unorder database checks
Break out the path into a separate variable to avoid the weird line break.