I wrote a comparator to sort a priority queue in increasing order of the second term, and then increasing order of the first term:
struct Comp { bool operator() (pair<int, int> a, pair <int, int> b) { if (a.second!=b.second) return a.second<b.second; else { return a.first<b.first; } } }; Generally, if I were to write a comp function for an array struct we would use the less than "<" operator to sort in increasing order, but for this priority queue, I've had to use the > operator to make it print the elements correctly in increasing order through q.top(). Does a priority_queue's "sort" make the "top" element the largest element if I use the "<" operator or least element?
operator<implies a max-heap.std::sortsort arrays in the ascending order, butstd::make_heapputs the largest element first. But heap is not a sorted array.