Just create a Comparator<Interval> that compares on startup time:
public class IntervalStartComparator implements Comparator<Interval> { @Override public int compare(Interval x, Interval y) { return x.getStart().compareTo(y.getStart()); } }
Then follow these steps:
Collections.sort(intervals, new IntervalStartComparator());
source share