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
Spacing.