Support ordering of database entries

Add the option to order the results from a database before checking if
they are the expected values.