String sorting problem

Hey what is the problem with this code , only one test case is getting passed

hello @soumyabhardwaj75

ur logic for checking whether one string is prefix of other string or not is incorrect.

it should like ->

bool comparator(string &a,string &b){
	if(a.size()<=b.size() && b.substr(0,a.size())==a) {return false;}
	else if(b.size()<=a.size() && a.substr(0,b.size())==b) {return true;}
	else{ return a<b;}
}

Can u write it in a simpler way ?

@soumyabhardwaj75

i am checking whether smaller string is prefix of bigger string or not.

this condition is to decide which string is bigger.

this condition is getting substring from bigger string and then comparng with smaller string.