java中文字符串按拼音排序 代码(转)
import java.text.Collator;
import java.util.Arrays;
import java.util.Comparator;
public class SortPinyin {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
String[] arr = { "张三","张A", "李四", "王五", "赵六", "F-16", "12345", "^%$%"};
Arrays.sort(arr, cmp);
for (int i = 0; i < arr.length; i++)
System.out.println(arr[i]);
System.out.println();
}
}
import java.util.Arrays;
import java.util.Comparator;
public class SortPinyin {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
String[] arr = { "张三","张A", "李四", "王五", "赵六", "F-16", "12345", "^%$%"};
Arrays.sort(arr, cmp);
for (int i = 0; i < arr.length; i++)
System.out.println(arr[i]);
System.out.println();
}
}