diff --git a/src/main/java/swm_nm/morandi/domain/testDuring/service/TempCodeService.java b/src/main/java/swm_nm/morandi/domain/testDuring/service/TempCodeService.java index 11d12fa8..ac193a44 100644 --- a/src/main/java/swm_nm/morandi/domain/testDuring/service/TempCodeService.java +++ b/src/main/java/swm_nm/morandi/domain/testDuring/service/TempCodeService.java @@ -66,12 +66,15 @@ public List getTempCode(Tests test) Map tempCodes = hashOps.entries(tempCodeKey); - return tempCodes.keySet().stream().map(problemNumber-> TestCodeDto.builder() - .cppCode(tempCodes.get(problemNumber).getCppCode()) - .pythonCode(tempCodes.get(problemNumber).getPythonCode()) - .javaCode(tempCodes.get(problemNumber).getJavaCode()) - .problemNumber(Integer.parseInt(problemNumber)) - .build()).collect(Collectors.toList()); + return tempCodes.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .map(entry -> TestCodeDto.builder() + .cppCode(entry.getValue().getCppCode()) + .pythonCode(entry.getValue().getPythonCode()) + .javaCode(entry.getValue().getJavaCode()) + .problemNumber(Integer.parseInt(entry.getKey())) + .build()) + .collect(Collectors.toList()); } public PracticeProblemCodeDto getPracticeProblemTempCode(Long practiceProblemId) {