Assuming:
val l1 = List(1,2,3)
val l2 = List(2,3,1)
I want a method that confirms that l1 is equal to l2 (as in same contents but different order). Is there an API method on List/Seq to do this?
l1.sameElements(l2)
does not work as it verifies order as well.
I've come up with the following:
l1.foldLeft(l1.size == l2.size)(_ && l2.contains(_))
Is there anything more succinct than the above to do this comparison?