You are viewing a single comment's thread. Return to all comments →
List<String> numbers = new ArrayList<>(); int n = scanner.nextInt(); for (int j = 0; j < n; j++) { numbers.add(scanner.next()); } numbers .stream() .parallel() .sorted((s1, s2) -> { if (s1.length() != s2.length()) { return s1.length() - s2.length(); } else { for (int i = 0; i < s1.length(); i++) { if (s1.charAt(i) != s2.charAt(i)) { return s1.charAt(i) - s2.charAt(i); } } } return 0; }) .forEachOrdered(System.out::println);
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →