Implement orderByPriority filter and maintain internal priority index