本文介绍了如何使用Collections和Comparator按升序对ArrayList进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 Comparator
按升序对 ArrayList
进行排序?我知道如何使用以下降序对其进行排序:
How to sort an ArrayList
in ascending order using Comparator
? I know how to sort it in descending order using:
Comparator mycomparator = Collections.reverseOrder();
然后
Collections.sort(myarrayList,mycomparator);
只是想知道如何使用集合和比较器按升序对其进行排序?谢谢!
just want to know how to sort it in ascending order using Collections and comparator? Thanks!
推荐答案
把它扔出去......你不能这样做:
Just throwing this out there...Can't you just do:
Collections.sort(myarrayList);
虽然已经过了一段时间......
It's been awhile though...
这篇关于如何使用Collections和Comparator按升序对ArrayList进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!