Vector 03 - using <pair>

Can someone please tell me how the comparator function is working. My doubt is that if we write return a>b, then it takes control over swap function and do swapping only if a>b??

@a19JE0093
hello akshat,
if in compare function
we have written
bool cmp(int a,int b){
return a > b;
}
a is first number b is second number

with a>b we are telling that a should be bigger then b .
if it is not then swapping is performed.

for example
a)
if we want to sort array of number in ascending number then our comparator should look like.

bool cmp(int a,int b){
return a < b;
}
a < b because we want our first number smaller than then second number (number that comes later in array)

b)
if we want to sort array of number in descending number then our comparator should look like.

bool cmp(int a,int b){
return a > b;
}
a > b because we want our first number bigger than then second number (number that comes later in array)

Thank You So much sir. You have provided me new perception to think out…Great explanation sir.