(maint) Sort both sets of classes when synchronizing

This fixes a failure I was getting intermittently in integration tests. The
classes loaded from the db were not consistently sorted which would sometimes
result in failures in synchronize-classes.