title: How to sort ArrayLists using booleans in java?
body: <p>I have an ArrayList with custom objects. They contain a checkbox object that I want to sort on. I am using this comparator function to sort it:</p>
  
  <p>I am using the XOR operator to check if they are equal to each other, then negate it.</p>
  
  <p>However this is not working, and the list is staying in the same order.</p>
  
  <p>Does anyone know whats wrong?</p>
  
  <pre><code>public class CustomSelectSort implements Comparator&lt;ObjPerson&gt; {
      @Override
      public int compare(ObjPerson o1, ObjPerson o2) {
          return !(o1.select.isChecked() ^ o2.select.isChecked()) ? 1 : -1;
      }
  }
  </code></pre>