I have created a binary heap, which represents a priority queue. It\'s just classical well known algorithm. This heap schedules a chronological sequence of different events
One solution is to add time of insertion attribute to the inserted element. That may be just a simple counter incremented each time a new element is inserted into the heap. Then when two elements are equal by priority, compare the time of insertion.