It will depend on what you put in I would guess.
If I put in a Blissey first, and someone comes along and puts in a Pidgey next, then it will come down to the attacker.
The attacker would need to kill my Blissey first - then they can leave, and start again with my Blissey, or instead of leaving they continue to fight the Pidgey next.
I would imagine it will take more fights to fully remove my lvl36 Blissey than it will to remove a lvl4 Pidgey.
So if the attacker goes through the full line up each time - I expect the pidgey will be out first.
...but because they have the option to attack the Blissey first, and then log out and start again on the Blissey, then the attacker gets to choose who will leave the gym first.