couldn't you be doing a
val maxPriority = setDraft.map(_.cf3PolicyDraft.priority).max
val samePriority = setDraft.filter(_.cf3PolicyDraft.priority == max).sortBy(_.directiveId.value)
?