Confused about writing out electron configurations
For a given configuration, the order of writing the orbitals is not
  completely fixed since only the orbital occupancies have physical
  significance. For example, the electron configuration of the titanium
  ground state can be written as either $\mathrm{[Ar] \, 4s^2 3d^2}$ or $\mathrm{[Ar] \, 3d^2 4s^2}$.
  The first notation follows the order based on the Madelung rule for
  the configurations of neutral atoms; $\mathrm{4s}$ is filled before $\mathrm{3d}$ in the
  sequence $\ce{Ar, K, Ca, Sc, Ti}$. The second notation groups all orbitals
  with the same value of $n$ together, corresponding to the
  "spectroscopic" order of orbital energies that is the reverse of the
  order in which electrons are removed from a given atom to form
  positive ions; $\mathrm{3d}$ is filled before $\mathrm{4s}$ in the sequence $\ce{Ti^4+, Ti^3+, Ti^2+, Ti+, Ti}$.


Source: Wikipedia article on electron configuration.