Algorithms such as sorting and filtering depend upon size of a structure, i.e. the number of elements in a structure. If you wish to arrange your elements in a specified order and select only a subset of these elements, it is suggested that you first filter the elements according to your criteria and then sort them as this potentially reduces the number of elements to be sorted, thus reducing the overall time spent performing this operation.
val subset = elements.sortWith(_ < _).filter(x => shouldSelect(x))
val subset = elements.filter(x => shouldSelect(x)).sortWith(_ < _)