Sort Array in Ascending Order
Here array elements are arranged in the lowest to the highest order. To do this, we can use the following ways.
- Using the sort() Method
- Using the for loop
Using the sort() Method
example:

output:

Java provides user-defined class named Array in java.util package. It provides sort() to sort an array in ascending order.
Using the for Loop
example:

output:

In here we use two for loops. The outer loop will select an element, and the inner loop allows us to compare the selected element with the rest of the elements.