How to compare two arrays of integers order-insensitively
<p>I want Java code that can compare in this way (for example):</p>

<pre><code>&lt;1 2 3 4&gt;  = &lt;3 1 2 4&gt;
&lt;1 2 3 4&gt; != &lt;3 4 1 1&gt;
</code></pre>

<p>I can't use hashmap table or anything; just pure code without library. </p>

<p>I know there are two ways.</p>

<ol>
<li>sort them and compare the array index by index</li>
<li><p>use two for loops and compare the outer index with the inner index. I have been trying with this but still not working:</p>

<pre><code>for(int i = 0; i &lt; n; i++)
{
    for(int j = 0; j &lt; n; j++)
    {   
        if(a[i] != a[j] &amp;&amp; j == n)
            return false;
    }
}
return true;
</code></pre></li>
</ol>

<p>anything wrong with the code ? thanks</p>
