一个对含中文字符串在内的字符串排序简便方法
Posted 1501220038
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个对含中文字符串在内的字符串排序简便方法相关的知识,希望对你有一定的参考价值。
public class StringSort
public static void main(String[] args)
String[] arr = "1101", "1100", "1001", "1110","1100","1101","0010","1000","0101","0011","1110","1011","0111","0110","1000","0100","1010",
"aabb","aabc","abab","baba","acbc","baca","bcab","cacb","cbba","你","我","他","你好","我好","他好","她好";
Comparator<Object> cmp = Collator.getInstance(java.util.Locale.CHINA);
Collections.sort(Arrays.asList(arr),Collections.reverseOrder(cmp));
//想应用拼音排序只能用reverseOrder方法,不过如果需要正排可以对数组反向读取
for(int i=0;i<arr.length;i++)
System.out.println(arr[i]);
中文字符串是按拼音排序的以上是关于一个对含中文字符串在内的字符串排序简便方法的主要内容,如果未能解决你的问题,请参考以下文章
JavaScript:三种简便方法生成重复的字符串(字符串乘法)