implement sort balls functionality.