Most elements are going to follow the Aufbau principle, this is the filling order given in the original post. The exceptions come in the transition metals mostly and occur when you can achieve a half filled subshell (for d and f) or a full d or f subshell. This happens for the Cr group which have nd5 ms1 and in the Cu group, having nd10 ms1. I am fairly certain this happens for rare earth metals as well.
Things get a bit hairy with elements that are filling higher energy orbitals too because these orbitals are extremely close in energy and I suppose spectroscopy or high level calculations are used to sort them out.