Sort the strings

I watched Prateek bhaiya’s tutorial on it, but I am not really getting it tbh.
Can someone explain this problem’s approach?
The Problem