Fix the sorting order

Report a typo

Here is a program that reads unordered numbers from the standard input, converts them to numbers, sorts and multiplies by two. Unfortunately, the sorting order is not preserved when displaying numbers. Please, fix it somehow!

Sample Input 1:

4 2 3 0 1

Sample Output 1:

0
2
4
6
8
Write a program in Java 17
import java.util.Arrays;
import java.util.Scanner;

class ParallelMapping {
private static final Scanner SCANNER = new Scanner(System.in);

public static void main(String[] args) {
Arrays.stream(SCANNER.nextLine().split("\\s+"))
.map(Integer::parseInt)
.sorted()
.map(n -> n * 2)
.parallel()
.forEach(System.out::println);
}
}
___

Create a free account to access the full topic