How our own comparator function works as given in editorial myCompare function please let me know?
How it takes two variable and how the return value effects it
Implementation of our own comparator function
struct Interval
{
int start, end;
};
bool compareInterval(Interval i1, Interval i2)
{
return (i1.start < i2.start);
} 3m ✓
is code me suppose hme ek structure array ko sort krna hai uske start variable ke hiasb se
so hm inbuilt sort function apne structure ke lie to nhi lga skte so hm comparator function use krenge 2m ✓
which will take 2 objects for comparing so hm un do object ki start ko compare krenge taki hm use start ke acc sort kr ske so i1 ka start agr chota hai to comparator true return krega and which will get to know to sort function that hm apne stru ko start ke acc sort krna chahte hai increasing order me just now ✓
Hope this resolves your doubt