我有一个MasterPayee对象,基于收款人类别代码按字母顺序排序,现在我需要获得其他服务类别代码最后的排序名单使用Java比较器,但具有固定值的对象排序应该在排序列表中的最后一个值
列表排序后应用
Financial and Insurance services
Government Sectors
Other Services
Telecommunications and Utilities
Transportation Services
必需名单如下
Financial and Insurance services
Government Sectors
Telecommunications and Utilities
Transportation Services
Other Services
需要acheive其他服务在列表的最后比较使用对列表进行排序
Collections.sort(masterPayees, getCategoryNameComparatorByMasterPayee());
private Comparator<MasterPayee> getCategoryNameComparatorByMasterPayee() {
Comparator<MasterPayee> categoryNameComparatorByMasterPayee = new Comparator<MasterPayee>() {
public int compare(MasterPayee o1, MasterPayee o2) {
return (((MasterPayee) o1).getPayee_category().toString()
.compareToIgnoreCase(((MasterPayee) o2).getPayee_category().toString()));
}
};
return categoryNameComparatorByMasterPayee;
}
其他服务应始终维持在排序列表继
的可能的复制[具有部分明确的,然后另一顺序订购?](http://stackoverflow.com/questions/42125743/ordering -with-partial-explicit-and-then-another-order) – MikaelF