java排序
天蓬老师
天蓬老师 2017-04-18 10:52:58
0
6
563

有一个数组
[10-20,41-50,31-40,51-60,21-30],使他按照10-20,21-30,...的顺序排序有什么高效的方法吗?谢谢

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(6)
PHPzhong

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.

迷茫

For sorting, there are many classic sorting algorithms. Just change the size comparison method to your own and it will be ok.

巴扎黑

Rewrite the compareTo method, remove the ‘-’ in the middle and convert it to an int comparison number

刘奇

What do you mean? Two-dimensional array?

小葫芦

(1) Apply Collections framework: implement the comparator interface and rewrite the compare method in it.
(2) Override the CompareTo method under String type

刘奇

When sorting, calculate the absolute value of the elements, and then choose different sorting methods according to the number of elements

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!