CodePudding user response:
The sorting?public static void the sort (int [] arr) {
For (int I=1; I & lt; Arr. Length; I++) {
For (int j=I; J> 0; J -) {
If (arr [j]break;
} else {
int temp=arr[j];
Arr=arr [j] [1];
Arr [1]=temp;
}
}
}
}
CodePudding user response:
Upstairs is a bubble sort it
,2,3,6,0 Integer array []={1, 1, 2, 3, 7, 10, 8};
ListList=Arrays. AsList (array);
The Collections. The sort (list, new Comparator() {
@ Override
Public int the compare (Integer o1, o2) Integer {
Return to o2.com pareTo (o1);
}
});
System.out.println(list);
Output: [8, 7, 6, 3, 2, 1, 0, 1, 2, 3, 10]