Microsoft Interview Question

Solve the ball sorting algorithm and explain it.