Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class CustomComparator {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- Arrays.stream(sc.nextLine().split("\\s+"))
- .map(Integer::parseInt)
- .sorted((f, s) -> {
- int result = 0;
- if (f % 2 == 0 && s % 2 != 0) {
- result = -1;
- } else if (f % 2 != 0 && s % 2 == 0) {
- result = 1;
- } else {
- result = f - s;
- }
- return result;
- })
- .forEach(e -> System.out.print(e + " "));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement