java.util.Arrays클래스 import 필요
Arrays.sort(배열명);
int[] arr = {3, 2, 6, 4, 1, 5};
Arrays.sort(arr); // 1, 2, 3, 4, 5, 6
Arrays.sort(배열명, Collections.reverseOrder());
public static <T> void sort(T[] a, Comparator<? super T> c) {
if (c == null) { // 오름차순
sort(a);
} else { // 내림차순
if (LegacyMergeSort.userRequested)
leegacyMergeSort(a, c);
else
TimSort.sort(a, 0, a.length, c, null, 0, 0);
}
}Comparator<? super T> c인데, 객체로 받아오게 되어있어 int는 기본형으로 불가능하다.// int -> Integer 형변환
int[] arr = {3, 2, 6, 4, 1, 5};
Integer[] arr1 = Arrays.stream(arr).boxed().toArray(Integer[]::new);
Arrays.sort(arr, Collections.reverseOrder()); // 6, 5, 4, 3, 2, 1
String[] arr = {"d", "a", "c", "b"};
Arrays.sort(arr, Collections.reverseOrder()); // d, c, b, a