in reply to Shifting an Array

why not use hash? you can add hash entries with priority as keys and as values the array content and at the end sort by keys (priority), and dump the sorted values to an array (if you need an array eventually).

Hotshot