dsaiztc
6/7/2014 - 9:46 AM

Sorting lists in java.

Sorting lists in java.

Collections.sort(myList, new Comparator<MyObject>() 
{
  public int compare(MyObject o1, MyObject o2) 
  {
      if (o1.getDateTime() == null || o2.getDateTime() == null)
        return 0;
      return o1.getDateTime().compareTo(o2.getDateTime());
  }
});