the teacher helps the children to sort out their problems.
I need time to sort myself out.
It means to address the shortcomings and point it in the right direction.
And in informal style, "I'll sort him out" can mean "I'll beat him", "I'll punish him", "I'll give him a hiding (to remember)".