-5

how to sort an array with any number of elements in java?

I create an array that allows the user to choose the number of elements but I don't know how to sort it.

this is the array code

Scanner input = new Scanner(System.in);
            System.out.print("Enter the size of the array: ");
            int r = input.nextInt();
            int[] list = new int[r];
            init(list);

1 Answers1

1

You can try

Arrays.sort(list);
Anton Mukhin
  • 109
  • 4