Sorting numbers

Report a typo

Implement a method for sorting a given array of integers in ascending order.

You can use any algorithm for sorting it.

Sample Input 1:

3 1 2

Sample Output 1:

1 2 3 
Write a program in Java 17
import java.util.Arrays;
import java.util.Scanner;

public class Main {

public static void sort(int[] numbers) {
// write your code here
}

/* Do not change code below */
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
String[] values = scanner.nextLine().split("\\s+");
int[] numbers = Arrays.stream(values)
.mapToInt(Integer::parseInt)
.toArray();
sort(numbers);
Arrays.stream(numbers).forEach(e -> System.out.print(e + " "));
}
}
___

Create a free account to access the full topic