I need to check whether two arrays contain the same data in any order.
Using the imaginary compare
method, I would like to do:
arr1 = [1,2,3,5,4]
arr2 = [3,4,2,1,5]
arr3 = [3,4,2,1,5,5]
arr1.compare(arr2) #true
arr1.compare(arr3) #false
I used arr1.sort == arr2.sort
, which appears to work, but is there a better way of doing this?