Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 34ffbcc

Browse files
authored
Update and rename Easy/Reorder Data in Log Files.java to Medium/Reorder Data in Log Files.java
1 parent 617557c commit 34ffbcc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Easy/Reorder Data in Log Files.java renamed to Medium/Reorder Data in Log Files.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ public String[] reorderLogFiles(String[] logs) {
33
List<String> letterLogs = new ArrayList<>();
44
List<String> digitLogs = new ArrayList<>();
55
for (String log : logs) {
6-
String[] split = log.split("\\s+");
7-
if (Character.isDigit(split[1].charAt(0))) {
6+
if (Character.isDigit(log.split("\\s+")[1].charAt(0))) {
87
digitLogs.add(log);
98
} else {
109
letterLogs.add(log);
1110
}
1211
}
1312
letterLogs.sort(Comparator.comparing((String o) -> o.substring(o.indexOf(' ') + 1))
14-
.thenComparing(o -> o.substring(0, o.indexOf(' '))));
13+
.thenComparing(o -> o.split("\\s+")[0]));
1514
letterLogs.addAll(digitLogs);
16-
return letterLogs.toArray(new String[]{});
17-
}
15+
return letterLogs.toArray(new String[0]);
16+
}
1817
}

0 commit comments

Comments
 (0)