Bool compare function

i didnt understand the case when the lengths of the 2 strings are equal then what is meant by return a<b

also by writing a.length()>b.length()… how are we ensuring that the greater length string gets the higher priority as we dont know which string will be allocated to the a parameter and which to the b parameter in the compare function.

also how can we return anything other than true or false from a bool function

@vector.9974, coming to your first question, " when the lengths of the 2 strings are equal then what is meant by return a<b", returning a<b, means that we are placing the string which is lexicographically smaller before the other string and for “how are we ensuring that the greater length string gets the higher priority”, we don’t have to ensure anything the comparator function will take care of everything all we need to tell the comparator function is how to compare between two string a and b , if the comparator returns true means place a before b in the vector, and vice versa , “how can we return anything other than true or false from a bool function” we can’t as the return type of comparator function is boolean.

In case of any doubt feel free to ask :slight_smile:
Mark your doubt as RESOLVED if you have no further doubt

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.