title: Arrays Equals Ignoring Order
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10154305/java-checking-equality-of-arrays-order-doesnt-matter">Java: Checking equality of arrays (order doesnt matter)</a>  </p>
  </blockquote>
  
  
  
  <p>I have two arrays :</p>
  
  <pre><code>String[] a1 = {"a", "b", "c"};
  String[] a2 = {"c", "b", "a"};
  </code></pre>
  
  <p>I need to check if both contains same elements (and of same length) <strong>irrespective of order</strong> of elements.</p>
  
  <p>I tried <code>Arrays.equals(a1, a2)</code> but it considers order of element.
  <code>org.apache.commons.lang.ArrayUtils</code> does not provide this thing.</p>
  
  <p>I know I can achieve the same by creating my own method (checking for same length, then sorting both array and then using <code>Arrays.equals(a1, a2)</code>) but wanted to know if this thing is provided in any API or there is more smart way to do the same.</p>