Added support to sort by priority