1. 程式人生 > >Java實現按漢語拼音的排序

Java實現按漢語拼音的排序

col string locale TE java In local ava 排序

public class sortByPinyin {
    public static void main(String[] args) {
          String[] arr = { "劉劉", "李飛", "王五", "老三", "貝貝", "啊三" };
          Collator cmp = Collator.getInstance(java.util.Locale.CHINA);
          Arrays.sort(arr, cmp);
          List<String> list = Arrays.asList(arr);
          System.out.println(list);
	}
}

Java實現按漢語拼音的排序