How can I sort a List set in java? The front-end time encounters a structure sorting List similar to this in the work. > What about sorting by a key value in Map? The collection is generated as follows:
Public void sortList () {List
> List = new ArrayList
>>(); Int group = 0; for (int I = 0; I <10; I ++) {List
> TempList = new ArrayList
> (); Group = new Random (). nextInt (45); for (int j = 0; j <2; j ++) {Map
Map = new HashMap
(); Map. put ("group", group + ""); tempList. add (map);} list. add (tempList) ;}for (int I = 0; I
The group sequence is as follows:
group ==43group ==25group ==28group ==32group ==19group ==20group ==25group ==21group ==24group ==36
The sorting function is:
Public List
> SortResList (List
> List) {if (list! = Null & list. size ()> 0) {for (int I = 0; I
This sorting function uses the idea of Bubble sorting. The main idea is to call API Collections. swap (List
List, int I, int j!
The sorted result is: after sort, group = 3 group = 9 group = 9 group = 10 group = 12 group = 23 group = 24 group = 36 group = 43 group = 44
------- The road is long, and I will go up and down