String sort problem

How i implement the compare function if string is a subset of another string

Hey @Alfred

bool compare(string a, string b){

    if (a.find(b)==0 || b.find(a)==0){  //If a was prefix of b or b is prefix of a

        return a.length() > b.length(); //then we place the one with greater length before other

    }   

    return a < b; //else we place by dictionary order

}

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.