Trying to figure out which one is more optimal to use and implement.
One efficient way to implement a priority queue is heapsort O(n logn).
Another way I was thinking was to use js object. By inserting the priority value (integer/number) as the key in the js object.
Given that when going enumerating a js object in ES6 we can get keys that are integer indices (if applicable), in ascending order. Does ES6 introduce a well-defined order of enumeration for object properties?
We can possible use the js object with integer being keys as priority queue and end up with a runtime of O(n). Object.keys() complexity?
const priorityQueue = {3:1,20:1,10:1,15:1,};
console.log(Object.keys(priorityQueue));
priorityQueue[5]=1;
console.log(Reflect.ownKeys(priorityQueue));