Reputation:
I have list of list of integers.
List(List(1, 1, 1, 1), List(2, 1, 1), List(2, 2))
I want to get the minimum sized list from that list which is List(2,2). What is the recommended way of doing this in Scala ?
Upvotes: 3
Views: 87
Reputation: 62835
Almost duplicate of another question that was asked today:
val xs = List(List(1, 1, 1, 1), List(2, 1, 1), List(2, 2))
xs.minBy(list => list.length)
// res0: List[Int] = List(2, 2)
Upvotes: 3