<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
private TermActiveComarator activeComarator;
ComparatorChain comparatorChain = new ComparatorChain();
comparatorChain.addComparator(activeComarator);
comparatorChain.addComparator(startDateComparator);
Collections.sort(list, comparatorChain);
public class TermActiveComarator implements Comparator<TermDto> {
@Override
public int compare(TermDto o1, TermDto o2) {
Boolean a1 = new Boolean(o1.isActive());
Boolean a2 = new Boolean(o2.isActive());
return a2.compareTo(a1);
}
}
No comments:
Post a Comment