One protocol is that when royals are "lined up" they are ordered by who has been reigning the longest would enter first.
For example, at a funeral the longest reigning monarch would "head" the procession of royal guests. In most cases it would be QEII if she attended an event. I am not sure what the protocol was exactly when heirs attend in place of their parents -- for example Albert for Prince Ranier and Prince Charles or Prince Phillip for Queen Elizabeth II.
Sometimes the protocol is broken for personal reasons. One recent example I can come up with was that at Prince Claus of the Netherlands' funeral, King Juan Carlos and Queen Sofia were placed before longer reigning monarchs because of their friendship with Queen Beatrix.
I suppose that when there are occasions with royal courts with family members from other royal houses such protocol might also be broken for family ties, such as the Danish or Belgian courts.
I was a bit confused at the Swedish King's 60th birthday when the escorting seemed a bit random: The second gala night there were pictures of Mary on the arms of Willem (with Maxima) and then with Harald (with Sonja) and then her cousin-in-law Nikolaos, and likewise of Victoria being escorted by Phillippe (with Mathilde) and then with her brother and her sister.