Согласно документу для спискаразница между отсортированные и SortBy
def sorted[B >: A](implicit ord: math.Ordering[B]): List[A]
Sorts this list according to an Ordering.
def sortBy[B](f: (A) ⇒ B)(implicit ord: math.Ordering[B]): List[A]
Sorts this List according to the Ordering which results from transforming an implicitly given Ordering with a transformation function.
Когда вы используете один и когда бы вы использовать другой? Покрывает ли сценарий другой вариант?
'xs.sorted (math.Ordering.by [String, Int] (_. Length))' – Debilski
@Debilski, вы обманываете! ;-) –
@ om-nom-nom отсортировано, вы можете передать пользовательский объект. Итак, когда пользовательский объект лучше, чем пользовательская функция? –