Int[] arr = {45, 34, 53, 43};
One, directly select the sort
system.out.println (arrays.tostring (arr)); for (int i=0;i<arr.length;i++< Span style= "color: #000000") { int tem = I; for (int j=i;j<arr.length;j++< Span style= "color: #000000") { if (Arr[j] < Arr[tem]) {tem = J; }} int temp1 = Arr[i]; Arr[i] = Arr[tem]; Arr[tem] = Temp1; } System.out.println (Arrays.tostring (arr));
Two, bubble sort
System.out.println (arrays.tostring (arr)); int temp =-1; for (int i=0;i<arr.length;i++) { for (int j=i+1;j<arr.length;j++) { if(arr[i]>arr[j]) { = arr[i]; = Arr[j]; = temp;}} } System.out.println (arrays.tostring (arr));
Three, reverse sort
System.out.println (arrays.tostring (arr)); for (int i=0;i<arr.length/2;i++) { int temp = arr[i]; = Arr[arr.length-i-1]; Arr[arr.length-i-1] = temp; } System.out.println (arrays.tostring (arr));
Java sort (bubbling, direct selection, invert)