The energy of an electron in an orbital is determined by the values of the principal quantum number $(n)$ and the azimuthal quantum number $(l)$.
Rule $I$: The orbital with a lower value of $(n + l)$ has lower energy.
Example: The energy of $2p$ is higher than $2s$.
For $2s$: $n = 2, l = 0$,so $(n + l) = (2 + 0) = 2$.
For $2p$: $n = 2, l = 1$,so $(n + l) = (2 + 1) = 3$.
Since $2 < 3$,therefore $2s < 2p$.
Rule $II$: If two orbitals have the same $(n + l)$ value,the orbital with the lower value of $n$ has lower energy.
Example: The energy of $3p$ is lower than $4s$.
For $4s$: $n = 4, l = 0$,so $(n + l) = (4 + 0) = 4$.
For $3p$: $n = 3, l = 1$,so $(n + l) = (3 + 1) = 4$.
Since $3 < 4$,therefore $3p < 4s$.