Elements in priority_queue are not in sorted order while inserting?

Elements in priority queue i.e. HEAP at backend are sorted

  1. whenever pq.top() occurs in code OR
  2. they are sorted during insertion time only i.e. pq.push§?

At backend elements are not in the sorted form ?

Because in the output (9:22 time) it can be seen for every pq.top(), PersonCompare() was called which was checking for priority.

the insertion is heap happens in sorted order.

Bro thats the output even before the 1st result is printed, when u see how a priority queue is implemented using heap, ull realize that as soon as an element is added, heapify function is called, which restructures the heap acc. to max or min criteria ( here in the video since user-defined object PERSON is being used the overloaded function is used to sort it __ hence u see the output)
But actually, internally all values are sorted at the time of insertion itself.