How are validators selected?

If there are more than 50418 suitable candidates, the top 50418 are chosen based on the total amount of stake in their pool + a random number.