The ionization energy of the elements increases from left to right in the periodic table. The first ionization of magnesium is greater than that of aluminium because magnesium has a stable complete electronic configuration 1s22s22p63s2, so it requires more energy to remove the first electron from it, whereas aluminium has electronic configuration 1s22s22p63s23p1 which need lesser energy than that of magnesium. Similarly, phosphorus has more ionisation energy than sulphur due to the half filled electronic configuration in the phosphorus.
MgAlPS→IE.order⇒Al<Mg<S<P