title: Compare collection of integers
body: <p>For an implementation of <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Comparable.html" rel="nofollow"><code>Comparable&lt;&gt;</code></a> I am looking for a way to compare two instances of <code>Collection&lt;boolean[]&gt;</code>. I am already comparing the <code>boolean[]</code>'s by creating an integer representation (101 == 5) so I've narrowed it down to comparing two <code>Collection&lt;Integer&gt;</code>'s.</p>
  
  <p>How would I go about doing this?</p>
  
  <p>Simply comparing each integer does not work because given <code>collectionA = {1, 2}; collectionB = {2,1}</code>, the following example gives <code>cmp == 0</code>, while the collections are certainly different.</p>
  
  <pre><code>int cmp = 0;
  for(Integer a : collectionA)
    for(Integer b : collectionB)
      cmp += Integer.compare(a, b);
  </code></pre>
  
  <p>What other options do I have? I don't really care <em>how</em> they are sorted, just <em>that</em> they are sorted in a consisting manner. The collections may have different sizes.</p>
  
  <p>Edit:
  I am really looking for a <code>int compare()</code>, not an <code>equals()</code>. A more concrete example with the actual structure of my application looks like this</p>
  
  <pre><code>class MyArray implements Comparable&lt;MyArray&gt; {
      boolean[] array;
  
      int compareTo(MyArray another) {
          // This is implemented
      }
  }
  
  class MyCollection implements Comparable&lt;MyCollection&gt; {
      SortedSet&lt;MyArray&gt; collection;
  
      int compareTo(MyCollection another) {
          // Looking for this implementation
      }
  }
  </code></pre>