title: Java sort Arraylist and return sorted list
body: <p>Hello am trying to return a sorted Arraylist by date property  like in this <a href="https://stackoverflow.com/a/2784576/2506749">answer</a></p>
  
  <pre><code>public class CustomComparator implements Comparator&lt;MyObject&gt; {
  @Override
  public int compare(MyObject o1, MyObject o2) {
      return o1.getStartDate().compareTo(o2.getStartDate());
  }
  }
  </code></pre>
  
  <p>My question is how can i return a sorted list instead of returning an int... 
  <strong>What i need is just a method i pass it my list then it returns a sorted list.</strong></p>
  
  <p>In my case i have many items in list, i dont know whether it's possible to compare all items and sort them accordingly. </p>
  
  <p>Thanks in advance.</p>