title: Getting only first element of ArrayList that matches condition
body: <p>I've been trying to find possible answers, but found none.</p>
  
  <p>I've got an <code>ArrayList</code> full of custom objects. One of their fields is a <code>boolean</code>.</p>
  
  <p><strong>I want to put this object first, keeping the rest of elements</strong></p>
  
  <p>For instance, if I've got this list and <code>obj5</code> is the one with this boolean set to true:</p>
  
  <pre><code>obj3, obj2, obj5, obj7, obj9
  </code></pre>
  
  <p>I'd like to get this:</p>
  
  <pre><code>obj5, obj3, obj2, obj7, obj9
  </code></pre>
  
  <p><strong>EDIT: CAN'T USE LAMBDAS, JAVA 6</strong></p>
  
  <p><strong>EDIT 2: PLEASE NOTE THAT THE REST OF THE LIST MUST KEEP THE OLD ORDER</strong></p>
  
  <p><strong>EDIT 3: In short words, I need this program to output [B, A, C, D, E]:</strong></p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.List;
  
  public class Trip {
  
  @Override
  public String toString() {
      return name;
  }
  
  private String name;
  private boolean freeCancellation;
  
  
  public Trip(String name, boolean freeCancellation) {
      this.name = name;
      this.freeCancellation = freeCancellation;
  }
  
  static Comparator&lt;Trip&gt; myOrder = new Comparator&lt;Trip&gt;() {
      public int compare(Trip a, Trip b) {
          if (a.freeCancellation == b.freeCancellation) return 0;
          return a.freeCancellation ? -1 : 1;
      }
  };
  
  public static void main(String [] args){
      Trip t1 = new Trip("A", false);
      Trip t2 = new Trip("B", true);
      Trip t3 = new Trip("C", false);
      Trip t4 = new Trip("D", true);
      Trip t5 = new Trip("E", false);
  
  
      List&lt;Trip&gt; tripList = new ArrayList&lt;&gt;();
      tripList.add(t1);
      tripList.add(t2);
      tripList.add(t3);
      tripList.add(t4);
      tripList.add(t5);
  
      System.out.println(Arrays.toString(tripList.toArray()));
      Collections.sort(tripList, myOrder);
      //result should be [B, A, C, D, E]
      System.out.println(Arrays.toString(tripList.toArray()));
  }
  
  }
  </code></pre>