Consider the below arraylist
unsortedList = {6,"ball",3,1,"apple","cat",4}
it needs to be sorted by
sortedList = {1,"apple",3,4,"ball","cat",6}
Sort strings alphabetically. Sort numbers in ascending order. But pay attention to the following condition:
- Wherever an integer in an unsorted list is, it must be an integer in a sorted list.
- Wherever there is a line in an unsorted list, it should be a line in a sorted list.
Note that in the above example, all integers are sorted in ascending order, and all strings are sorted in ascending order, but the relative positions of integers and strings are not changed earlier.
java sorting arraylist algorithm
Kaleid-o-scope
source share