Difficulty in understanding comparator function for priority queue

c++STL quiz-1 ques 11. there they have implemented the priority queue and i am not able to understand how they are sorting the pq . please help me

the priority queue is sorting the pair according to the descending order of second if the second of two pairs are unequal else it sorting in ascending order according to the first of two pairs.

ankit i use this logic

#include<bits/stdc++.h>
using namespace std;

/* see this function favours when first is greater tha second /
/
it means that this will sort the list by descending order /
bool compareDescending(int firstElement, int secondElement){
/
returns true when first is larger than second */
return firstElement > secondElement;
}

/*
this function favours when first is smaller than second
it means that this function is gonna sort the list by ascending order
/
bool compareAscending(int firstElement, int secondElement){
/
returns true when first is smaller than second */
return firstElement < secondElement;
}

int main(){
int a[] = {2,5,1,6,11,9};
int n = sizeof(a)/sizeof(int);
sort(a,a+n,compareAscending);
for(auto i : a){
cout << i << " ";
}
cout << endl;
cout << “-------------------” << endl;
sort(a,a+n,compareDescending);
for(auto i : a){
cout << i << " ";
}
cout << endl;
return 0;
}

so it is sorting according to ascending order of second if they are unequal else descending order of first

can you explain me how you decide the order,

the one who has small value of second is given more priority and if their value are equal then the one who has larger value of first will be given the more priority

Actually in case of priority queue just remember that opposite happens than expected. if the sign is > then ascending order else descending order