title: Compare Intervals (JodaTime) in a list for overlap
body: <p>I have a list of intervals, and I need to compare them for overlaps.</p>
  
  <pre><code>List&lt;Interval&gt; intervals = new ArrayList&lt;&gt;();
  intervals.add(new Interval(dateTime1, dateTime2));
  intervals.add(new Interval(dateTime3, dateTime4));
  intervals.add(new Interval(dateTime5, dateTime6));
  </code></pre>
  
  <p>eg.
  dateTime1 = 2014-06-01
  dateTime2 = 2014-07-01</p>
  
  <p>dateTime3 = 2014-08-01
  dateTime4 = 2014-09-01</p>
  
  <p>dateTime5 = 2014-08-15
  dateTime6 = 2014-09-15</p>
  
  <p>In this case, there is an overlap between the 2nd and the 3rd interval. I can use the Interval.overlaps method to find that. I'm thinking of 2 for loops and going through each of the intervals in the list to compare. But that solution is O(n*n). What is a more efficient way to do this?</p>