有一个数组
[10-20,41-50,31-40,51-60,21-30],使他按照10-20,21-30,...的顺序排序有什么高效的方法吗?谢谢
PHPz2017-04-18 10:54:58
If there are only a few array elements, there will be no big difference in whichever sorting method you use.
Sorting algorithms can only show their respective advantages when the amount of data is relatively large.
迷茫2017-04-18 10:54:58
For sorting, there are many classic sorting algorithms. Just change the size comparison method to your own and it will be ok.
巴扎黑2017-04-18 10:54:58
Rewrite the compareTo method, remove the ‘-’ in the middle and convert it to an int comparison number
高洛峰2017-04-18 10:54:58
(1) Apply Collections framework: implement the comparator interface and rewrite the compare method in it.
(2) Override the CompareTo method under String type
怪我咯2017-04-18 10:54:58
When sorting, calculate the absolute value of the elements, and then choose different sorting methods according to the number of elements