Arrays sort排序

Arrays.sort默认是升序,如果我们需要降序排列数组?

Arrays.sort(distances);——升序

Arrays.sort(distances, Collections.reverseOrder());——降序

再说说Collections集合类,用来排序集合的

Collections.sort(list)——升序

Collections.reverse(list)——反序

Collections.reverseOrder()——降序

猜你喜欢

转载自blog.csdn.net/wang20y8/article/details/88537067
今日推荐