Is there a reason why there is no implicit Ordering for Lists in Scala?
val lists = List(List(2, 3, 1), List(2, 1, 3))
lists.sorted
error: could not find im
In newer Scala versions (tested with 2.12.5) there's an Ordering for Iterable[A]. Just ascribe the right type to your variable lists:
scala> val lists = List(List(2, 3, 1), List(2, 1, 3))
lists: List[List[Int]] = List(List(2, 3, 1), List(2, 1, 3))
scala> (lists: List[Iterable[Int]]).sorted
res0: List[Iterable[Int]] = List(List(2, 1, 3), List(2, 3, 1))
Or convert the elements to instances of Iterable[] (which is a no-op for instances of List[]):
scala> lists.map(_.toIterable).sorted
res1: List[Iterable[Int]] = List(List(2, 1, 3), List(2, 3, 1))