I don't understand the sorting order set by the comparator function.
This is the code of the comparator parameter passed to the priority queue:
struct CompareHeight {
bool operator()(Person const& p1, Person const& p2)
{
return p1.height < p2.height;
}
};
This is giving output in decreasing order of height
example output: 6 5 4 3 2
Shouldn't be output like : 2 3 4 5 6
A priority_queue
always starts with the largest element (highest priority), see e.g. here.