not able to understand what is a custom compare function and how does it work.
Custom compare in sorting of strings
Hey! I’m unable to understand your question, can you please elaborate what you exactly want to ask.
basically when we are sorting a string alphabetically using sort function, we made a custom compare function of type bool i am not able to understand how that function works
Hey Ashutosh, When we use sort function of stl we can pass a custom compare function which describes how we want to compare the two objects. For reference you can check this code.
bool compare(string a,string b){
return tolowerCase(a)<tolowerCase(b);
}
This code compares string a and b, return true if string a is lexicographically smaller than string b else it will return false.