首页 > 其他 > 详细

zenefits oa - sort integer array in lexographical order

时间:2016-02-01 15:06:02      阅读:220      评论:0      收藏:0      [点我收藏+]

[ 12 | 2434 | 23 | 1 | 654 | 222 | 56 | 100000 ]

Then the output should be:

[ 1 | 100000 | 12 | 222 | 23 | 2434 | 56 | 654 ]

建立自己的comparator:

Comparator<Integer> intLexCompare = new Comparator<Integer>() {
  int compareTo( Integer x, Integer y) {
      return x.toString().compareTo(y.toString();
  }
}  

Arrays.sort(nums, intLexCompare);

zenefits oa - sort integer array in lexographical order

原文:http://www.cnblogs.com/marc-leetcode/p/5175009.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!