Fix incorrect output ordering in tests in some cases #1825
This ensures that output from database tests are ordered by model id.
Some tests require that the output is exactly the same as some predefined values. However, the previous PR mentioned above introduced a change that caused output ordering to be changed on PostgreSQL, even though the data is exactly the same.
There shouldn't be any need to check for ordering of results unless that is the intended purpose of a specific test.
This just orders models inside collections by id after they are fetched from the database. This application side approach was chosen to avoid changing all the affected tests.