首页 > 代码库 > 一个对含中文字符串在内的字符串排序简便方法
一个对含中文字符串在内的字符串排序简便方法
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]); } } }
中文字符串是按拼音排序的
本文出自 “空空如也” 博客,谢绝转载!
一个对含中文字符串在内的字符串排序简便方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。