Just create a Comparator<Interval>
which compares by start times:
public class IntervalStartComparator implements Comparator<Interval> {
@Override
public int compare(Interval x, Interval y) {
return x.getStart().compareTo(y.getStart());
}
}
Then sort using that:
Collections.sort(intervals, new IntervalStartComparator());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…