Priority Queues have a priority value and data, for every entry.
Thus, when adding a new element to the queue, it bubbles up to the surface if it has a higher priority value than elements already in the collection.
When one calls pop, we get the data for the element with highest priority.
What is an efficient implementation of such a priority queue in Javascript?
Does it make sense to have a new object called PriorityQueue, create two methods (push and pop) that take two params (data, priority)? That much makes sense to me as a coder, but I'm uncertain of which data structure to use in the underbelly that will allow manipulation of the ordering of elements. Or can we just store it all in an array and walk through the array every time to grab the element with max priority?
What's a good way to do this?