Generally speaking, a sigma molecular orbital is higher in energy then a pi one.
O2 is particular because of Herr Hund's Rule: it is better for O2 to have two electrons, at the same energy, with the same spin.
So, for what concers O2, the sigma MO is 'fulfilled' before the two pi ones.