Ah yes, is the 1st/2nd/3rd place decided by who has the most Pokemon left + Wins?

So for example: Person A has 5-0 win, 3-0 win and 2-0 win as opposed to Person B, whom has 5-0 win, 2-0 win and 1-0 win, does that mean that Person A is first, and Person B second? Or is it solely based on your Win count?