Computer Science, asked by dibyajyotibose97, 1 month ago

write a Program to sort an array in java?​

Answers

Answered by neelrajK
1

Answer:

The sorting is a way to arrange elements of a list or array in a certain order. The order may be in ascending or descending order. The numerical and lexicographical (alphabetical) order is a widely used order.

In this section, we will learn how to sort array in Java in ascending and descending order using the sort() method and without using the sort() method. Along with this, we will also learn how to sort subarray in Java.

Answered by dhineshkarthik2323
1

Answer:

Program:

public class SortAsc {

public static void main(String[] args) {

//Initialize array.

int [] arr = new int [] {5, 2, 8, 7, 1};

int temp = 0;

//Displaying elements of original array.

System. out. println("Elements of original array: ");

for (int i = 0; i < arr. length; i++) {

Similar questions