OneBite.Dev - Coding blog in a bite size

sort items in array by asc in java

Code snippet on how to sort items in array by asc in java

  int[] array = {1, 3, 2, 5, 4};
  Arrays.sort(array);

This code snippet sorts an array of integers in ascending order. First, an array of integers is created and assigned to the int[] array variable. Then, the Arrays.sort() library function is called on the array, which will sort the items within it in ascending order. After running this code, the array will contain the integers in order from 1 to 5. This code is a simple and efficient way to sort arrays of integers.

java