Why don't you cache min and max priority after sorting?