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.
(1) Apply Collections framework: implement the comparator interface and rewrite the compare method in it. (2) Override the CompareTo method under String type
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