The configuration of cerium is
Ce -> 1s2 2s2 2p6 3s2 3p6 4s2 3d10 4p6 5s2 4d10 5p6 6s2 4f1 5d1
The filling of electrons follows Aufbau principle nicely till Z<20, however, introduction of d and f orbitals and resulting poor shielding affects predicted energy order. Lanthanoids have their atomic configuration with a variable occupancy of 4f energy level and a common 6s2 level.The energy level of the 5d sub-shell increases than that of the 4f sub-shell moving across period(57–71). As a result of the low energy of 4f sub-shell electrons occupy these sub-shells before occupying the 5d sub-shell. As we progress from atomic number 57 to 71, an electron is added in 4f energy level with increase in atomic number with the exception of some metals where the electron occupies a 5d energy level.
In case of Cerium, energy of 4f and 5d subshells are quite similar and thus explains the electronic configuration stated above.