Skip to content

Commit 1d353a5

Browse files
authored
Update Reorder Data in Log Files.java
1 parent 44323f0 commit 1d353a5

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Easy/Reorder Data in Log Files.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ public String[] reorderLogFiles(String[] logs) {
1010
letterLogs.add(log);
1111
}
1212
}
13-
letterLogs.sort((o1, o2) -> {
14-
String contentOne = o1.substring(o1.indexOf(" ") + 1);
15-
String contentTwo = o2.substring(o2.indexOf(" ") + 1);
16-
int c = contentOne.compareTo(contentTwo);
17-
if (c != 0) {
18-
return c;
19-
}
20-
return o1.substring(0, o1.indexOf(" ")).compareTo(o2.substring(0, o2.indexOf(" ")));
21-
});
13+
letterLogs.sort(Comparator.comparing((String o) -> o.substring(o.indexOf(' ') + 1))
14+
.thenComparing(o -> o.substring(0, o.indexOf(' '))));
2215
letterLogs.addAll(digitLogs);
23-
return letterLogs.toArray(new String[0]);
24-
}
16+
return letterLogs.toArray(new String[]{});
17+
}
2518
}

0 commit comments

Comments
 (0)