For primitive values like numbers and strings this is an easy solution:
a = [1,2,3]
b = [3,2,1]
a.sort().toString() == b.sort().toString()
The call to sort()
will ensure that the order of the elements does not matter. The toString()
call will create a string with the values comma separated so both strings can be tested for equality.