Pregunta de entrevista de Microsoft

Solve the ball sorting algorithm and explain it.