-3

Please advise the easiest way to sort an array of integers. I just recently started coding in java and would like to find how to do it quickly.

I think nothing is easier

import java.util.Arrays;
import java.util.Scanner;

public class Test {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] array = new int[n];
    for(int i = 0; i < n; i++) {
        array[i] = sc.nextInt();
    }
    Arrays.sort(array);
    System.out.println(Arrays.toString(array));
    }
}
DieMass
  • 13
  • 3

1 Answers1

1

This: https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(int[])

Arrays.sort(yourArray);
Not a JD
  • 1,864
  • 6
  • 14