Good to hear it’s working now!
You mean as you’ve kept model.train()?
If so, I think you are right. If you sort the data according to the classes, the mean and std of the samples might differ quite a lot between classes, so that the running estimates will get a higher influence of the last classes.
Of course it depends on the data you are using and since you are apparently using cat and dog pictures I wouldn’t expect the effect to be that bad.