Lanthanum has electronic configuration [$\ce{Xe}$] $4\mathrm{f}^0$ $5\mathrm{d}^1$ $6\mathrm{s}^2$. Why is the $4\mathrm f$ sub-shell not filled even though we know that $4\mathrm f$ is filled before $5\mathrm d$ sub-shell?
I know that for some elements energy level of $4\mathrm f$>$5\mathrm d$. Why is this so?