Doubt regarding comparision

what is the advantage of doing the same work in comparator class we could do it in direct comparison like a.name=b.name

While working with predefined functions of stl like sort any anything else, you will need a comparator. You cannot do it with direct comparison. Comparing using comparator is the standard way in such a case.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.