title: Sorting list of objects by date property
body: <p>I have an object that contains two LocalDate properties:</p>
  
  <pre><code>public class SomeObject {
      private LocalDate startDate;
      private LocalDate endDate;
  }
  </code></pre>
  
  <p>Constructor and stuff ommitted for brevity. I want to sort a list of these objects by their startdate and then assign the startdate of the next object to the previous object's enddate. To clarify, I start with a list of these objects:</p>
  
  <pre><code>SomeObject object1 = new SomeObject(LocalDate.parse("2015-01-01"), null);
  SomeObject object2 = new SomeObject(LocalDate.parse("2014-01-01"), null);
  SomeObject object3 = new SomeObject(LocalDate.parse("2016-01-01"), null);
  
  List&lt;SomeObject&gt; list = Arrays.asList(object1, object2, object3);
  </code></pre>
  
  <p>And after sorting it should return this:</p>
  
  <pre><code>for (SomeObject object : list) {
      System.out.println(object.startDate.toString() + " " + object.endDate.toString() );
  }
  
  2014-01-01 2015-01-01
  2015-01-01 2016-01-01
  2016-01-01 null
  </code></pre>
  
  <p>Each list will only contain 3 or 4 of these objects at most, but the code might have to process tens of thousands of these lists, so I'm looking for an efficient way to do this.</p>