3 ms·There is a structure for just this purpose which, funnily enough, is known as a "priority queue".by thaumasiotes 3y agoThere is a structure for just this purpose which, funnily enough, is known as a "priority queue".