Sir, I viewed the source code for sort() function.
Sorts the elements in the range @p [first , last) in ascending order, such that @p comp( (asterisk)(i+1),(asterisk)(i) ) is false for every iterator i in the range @p [first , last-1).
So, if I write the condition in “compare” function as
compare (int a, int b){
return a>b;
}
Basically, a = arr[i+1] and b = arr[i]
and whenever the condition a>b is false, it’ll swap the elements…?
That is, sorting is done to ensure that the condition inside the comparator stands false.
Is this reasoning correct or not…? If not, then please share the correct resoning.