Domanda di colloquio di Microsoft

Solve the ball sorting algorithm and explain it.