整型数组按照字典序排序

整型数组按照字典序排序

输入
...
0,1,2,3,5,7,8,1001,10
9
...
输出
...
0,1,10,1001,2,3,5,7,8
Collections.sort(list, new Comparator<Integer>() {
    @Override
    public int compare(Integer o1, Integer o2) {
         String A = o1 + "";
         String B = o2 + "";
         return A.compareTo(B);
    }
});
posted @ 2023-10-30 10:02  爱新觉罗LQ  阅读(11)  评论(0编辑  收藏  举报