How to write electronic configuration of p-orbitals? For example, the electronic configuration for the element boron can be writen as:
1s2 2s2 2p1
However, it is can be written more accurately by taking the different p-orbitals into account:

The electronic configuration with the different p-orbitals starting from boron ascending in atomic number:

B - 1s2 2s2 2px1
C - 1s2 2s2 2px1 2py1
N - 1s2 2s2 2px1 2py1 2pz2
O - 1s2 2s2 2px2 2py1 2pz2
F - 1s2 2s2 2px2 2py1 2pz2

Each type of 'p-orbital' can hold a maximum of 2 electrons. But the way they are assigned to which orbital is not always systematic e.g. the electrons do no wait till, pX orbital is full to be able to fill the next one (I know this has something to do with energy levels and trends in periodic table).
Can someone tell me how this works and how I can use it to be able to write electronic configurations for p-orbitals. It is much easier just using the summation of  px + py + pz = pX; but my teacher sometimes writes it out fully...
Electrons don't pair up in orbitals before each is singly occupied by Hund's rule of maximum multiplicity.
Writing out px, py, pz fully or using p^n notation (n=no of electrons in a p orbital) is a matter of context and circumstance rather than the standard convention; you might use the 'full version' when explaining bonding through hybridization but omit it while stating the electronic configuration of an atom generally. Both notations are quite interchangeable.