Check out example codes for "java sort int array". It will help you in understanding the concepts better.

Code Example 1

// an array of ints
int[] arr = {1, 2, 3, 4, 5, 6};

// an array of reverse sorted ints
int[] arrDesc = Arrays.stream(arr).boxed()
    .sorted(Collections.reverseOrder())
    .mapToInt(Integer::intValue)
    .toArray();

System.out.println(Arrays.toString(arrDesc)); // outputs [6, 5, 4, 3, 2, 1]

Code Example 2

public class InsertSort {  public static void main (String [] args) {   int [] array = {45,12,85,32,89,39,69,44,42,1,6,8};   int temp;   for (int i = 1; i < array.length; i++) {    for (int j = i; j > 0; j--) {     if (array[j] < array [j - 1]) {      temp = array[j];      array[j] = array[j - 1];      array[j - 1] = temp;     }    }   }   for (int i = 0; i < array.length; i++) {     System.out.println(array[i]);   }  }}

Code Example 3

import java. util. Arrays;
Arrays. sort(array);

Learn ReactJs, React Native from akashmittal.com