public class SortByChinese {
//测试
public static void main(String[] args) {
String[] a1 = {"保定","何子安","于小云","刘帝","刘何保定子安","刘","刘娜","家强","刘博"};
getSortOfChinese(a1);
for (int i = 0; i < a1.length; i++) {
System.out.println(a1[i]);
}
}
/**
*
* @param a String[]
* @return String[]
*/
public static String[] getSortOfChinese(String[] a) {
// Collator 类是用来执行区分语言环境这里使用CHINA
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
// JDKz自带对数组进行排序。
Arrays.sort(a, cmp);
return a;
}
}public class SortByChinese {
//测试
public static void main(String[] args) {
String[] a1 = {"小二","张三","李四","王五","刘七"};
getSortOfChinese(a1);
for (int i = 0; i < a1.length; i++) {
System.out.println(a1[i]);
}
}
/**
*
* @param a String[]
* @return String[]
*/
public static String[] getSortOfChinese(String[] a) {
// Collator 类是用来执行区分语言环境这里使用CHINA
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
// Arrays工具类对数组进行排序。
Arrays.sort(a, cmp);
return a;
}
}
试试对你的问题是否有用