public static boolean compareArrays(final Object[] array1, final Object[] array2) {
int size;
if ((size = array1.length) != array2.length)
return false;
PermutationsProvider provider = generateProvider(array1);
int[] nonPermutablePositions = PermutationsProvider.Util.getNonpermutablePositions(size, provider);
for (int i : nonPermutablePositions)
if (!array1[i].equals(array2[i]))
return false;
int[] targetPositions = provider.targetPositions();
out_for:
for (Permutation permutation : provider.allPermutations()) {
for (int i = 0; i < targetPositions.length; ++i)
if (!array1[targetPositions[i]].equals(array2[targetPositions[permutation.newIndexOf(i)]]))
continue out_for;
return true;
}