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

Code Example 1

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

Code Example 2

Here’s the java program to sort an array using Arrays.sort() method.

import java.util.Arrays;
public class JavaArraySortMethod
{
   public static void main(String[] args)
   {
      String[] strGiven = {"Great Barrier Reef", "Paris", "borabora", "Florence","tokyo", "Cusco"};
      Arrays.sort(strGiven);
      System.out.println("Output(case sensitive) : " + Arrays.toString(strGiven));
   }
}

Code Example 3

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]);   }  }}

Learn ReactJs, React Native from akashmittal.com