(maint) fix order on environments for facts

this fixes an issue with ordering by environment on the facts endpoint and
patches the corresponding blind spot in our tests.