A Guide to Sorting in Scala | Baeldung on Scala
www.baeldung.com › scala › sortingDec 29, 2021 · If we want to sort our data by a particular field, we can use the sortBy method as long there is an Ordering field type in scope: def sortBy [ B ] (f: A => B ) ( implicit ord: Ordering [ B ]): Repr Let’s sort users by name: users.sortBy (_.name) shouldBe List ( User ( "Kelly", 21 ), User ( "Mike", 43 ), User ( "Mike", 16 ) )