title: Joda DateTime array sort array by date time
body: <p>I have an arraylist of Joda DateTimes like this:</p>
  
  <pre><code>List &lt;DateTime&gt; nextRemindersArray = new ArrayList&lt;DateTime&gt;();
  nextRemindersArray.add(reminderOneDateTime);
  nextRemindersArray.add(reminderTwoDateTime);
  nextRemindersArray.add(reminderThreeDateTime);
  </code></pre>
  
  <p>I am trying to sort the dates in ascending order but I am having trouble:</p>
  
  <p>I googled it and found this page:</p>
  
  <p><a href="https://cmsoftwaretech.wordpress.com/2015/07/19/sort-date-with-timezone-format-using-joda-time/" rel="nofollow noreferrer">https://cmsoftwaretech.wordpress.com/2015/07/19/sort-date-with-timezone-format-using-joda-time/</a></p>
  
  <p>I tried it like this:</p>
  
  <pre><code>nextRemindersArray.sort(nextRemindersArray);
  </code></pre>
  
  <p>But it gives me the error:</p>
  
  <pre><code>Error:(1496, 37) error: incompatible types: List&lt;DateTime&gt; cannot be converted to Comparator&lt;? super DateTime&gt;
  </code></pre>
  
  <p>I then tried like this:</p>
  
  <pre><code>DateTimeComparator dateTimeComparator = DateTimeComparator.getInstance();
  nextRemindersArray.sort(nextRemindersArray, dateTimeComparator);
  </code></pre>
  
  <p>and also like this:</p>
  
  <pre><code>nextRemindersArray.sort(nextRemindersArray, new DateTimeComparator());
  </code></pre>
  
  <p>but all have errors.</p>
  
  <p>I tried the Joda time manual and that wasn't much help. How do I sort the array?</p>
  
  <p>Thanks in advance for your help</p>