Execute Promises Based on Custom Priority Ordering
Design a priority-based promise executor that accepts a list of tasks each tagged with a numeric priority level. Tasks with higher priority must be executed before lower-priority ones. Implement a min/max-heap or sorted queue to manage ordering. Handle ties, dynamic task insertion, and concurrency limits if applicable. This maps directly to real-world systems like job schedulers, render queues, and network request prioritization.