Tweaked iteration order for efficiency reasons

This is unlikely to be measurable, but it's a principle thing.