我正在尝试使用以下代码对节点列表进行排序:
private String sortPropertyName;
private void sortListUsingSortorder(List<MyNode> nodes, String sortOrder) {
BeanComparator comparator = new BeanComparator(sortPropertyName, new Comparator() {
public int compare(Object obj1, Object obj2) {
if ("dsc".equals(sortOrder)) {
return ((Comparable) obj2).compareTo(obj1);
} else {
return ((Comparable) obj1).compareTo(obj2);
}
}
});
Collections.sort(nodes, comparator);
}
}
我想使用 Collator 来实现以下排序:
AaÄäBbCcUuÜü
像这样的东西
Collator collator = Collator.getInstance(Locale.GERMAN);
collator.setStrength(Collator.PRIMARY);
Collections.sort(words, collator);
如何在我的排序代码中使用这个 Collator?