自己写了两种方法的中文比较器,
private class ListComparator implements Comparator{
Collator collator = Collator.getInstance();
public int compare(Object o1, Object o2) {
PIResource res1=(PIResource)o1;
PIResource res2=(PIResource)o2;
// String s1=new String(res1.getKoResource().getName().getBytes("GB2312"),"ISO-8859-1");
// String s2=new String(res2.getKoResource().getName().getBytes("GB2312"),"ISO-8859-1");
CollationKey s1=collator.getCollationKey(res1.getKoResource().getName());
CollationKey s2=collator.getCollationKey(res2.getKoResource().getName());
return s1.compareTo(s2);
}
}
Collections.sort(piResources, new ListComparator());