中文排序

import java.text.RuleBasedCollator;
import java.util.Arrays;
import java.util.Comparator;

public class sortCH {

    /**
     * @author zoukang
     * @date 2010.5.30 對名字或漢字進行排序
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Comparator cmp = (RuleBasedCollator) java.text.Collator.getInstance(java.util.Locale.CHINA);
        String[] array = { "张七", "李四", "王五", "阿康", "阿阿" };
        Arrays.sort(array, cmp);
        for (String str : array) {
            System.out.println(str);

        }
    }

}

你可能感兴趣的:(java)