排序——使用Collator进行本地化语言的排序

// This Comparator uses a Collator to determine the
// proper, case-insensitive lexicographical ordering
// of two strings.
class IgnoreCaseComp implements Comparator<String> {
Collator col;
IgnoreCaseComp() {
// Get a Collator for this locale.
col = Collator.getInstance(); //工厂方法
// Have it consider only primary differences.
col.setStrength(Collator.PRIMARY);
}
// Uses Collator's compare() method to compare strings.
public int compare(String strA, String strB) {
return col.compare(strA, strB);//采用Collator的compare方法
}
}

你可能感兴趣的:(本地化)