I am looking for a method that compares if 2 arrays have same elements.
Following implementations all return false when order of elements is differnet.
Array(2,1).sameElements(Array(1,2))
Array(1,2).deep == Array(2,1).deep
Array(1,2).corresponds(Array(2,1)){_ == _}
I am currently using it by sorting an array before comparison. But I believe there must be a much more efficient method for implementing this
Array(2,1).sorted.sameElements(Array(1,2).sorted)
res: true