1. Sorting arrays of basic data types
Note: (1) the sort () in the arrays class uses the " fast sorting method after tuning";
(2) An array of base data types such as int[],double[],char[], thearrays class simply provides the default ascending order, and does not provide a corresponding descending arrangement method .
(3) To sort the arrays of the underlying type in descending order, these arrays need to be converted into corresponding encapsulated class arrays, such as integer[],double[],character[], to sort the arrays of these classes. (In fact, it is better to sort the ascending order first, oneself in the order).
Sort the array in the default ascending order
Two ways to sort descending:
public static void Main (string[] args) {//method one: int arr[]={1,6,3,4};//Default ascending Arrays.sort (arr); for (int i=arr.length-1;i> =0;i--) {System.out.println (arr[i]);} Method Two: Applied to the object type or wrapper type, the base type is using comparable//Integer arr[]={1,6,3,4};//arrays.sort (arr, new Comparator () {//@Override// public int Compare (object O1, Object O2) {//return (integer) o2-(integer) o1;//}//});//for (int i=0;i<arr.length;i++) { System.out.println (Arr[i]);//}//}
Https://www.cnblogs.com/xudong-bupt/p/3168618.html
Java arrays class for array sorting