diff --git a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java index c54954f..7a41fd6 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java @@ -81,7 +81,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Comparator; import java.util.Date; import java.util.HashMap; @@ -671,12 +670,11 @@ public String doTermLoad(@PathVariable("courseId") String courseId, @PathVariabl // Make sure the sections are still sorted Comparator nameComparator = Comparator.comparing(SectionUIDisplay::getSectionName, Comparator.nullsFirst(Comparator.naturalOrder())); - Collection> sectionUIDisplays = rebuiltTermMap.values(); - for (List uiDisplay : sectionUIDisplays) { - if (uiDisplay != null) { - uiDisplay.sort(nameComparator); + rebuiltTermMap.values().forEach(sectionUIDisplays -> { + if (sectionUIDisplays != null) { + sectionUIDisplays.sort(nameComparator); } - } + }); model.addAttribute("activeCourseSections", rebuiltTermMap.get(currentCourse.getTerm())); model.addAttribute("sectionsMap", rebuiltTermMap); diff --git a/src/main/java/edu/iu/uits/lms/crosslist/service/CanvasTermComparator.java b/src/main/java/edu/iu/uits/lms/crosslist/service/CanvasTermComparator.java index 657158d..c9879ab 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/service/CanvasTermComparator.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/service/CanvasTermComparator.java @@ -43,8 +43,11 @@ public class CanvasTermComparator implements Comparator, Serializabl @Override public int compare(CanvasTerm ct1, CanvasTerm ct2) { + // This comparator is used for sorting terms in a map. We don't want it to ever return equal because + // that entry would not be added to the map. In case of equality, return in ABC order. if (TermHelper.getStartDate(ct1) == null && TermHelper.getStartDate(ct2) == null) { - return 0; + // if start dates are the same, return in ABC order + return ct1.getName().compareTo(ct2.getName()); } else if (TermHelper.getStartDate(ct1) == null && TermHelper.getStartDate(ct2) != null) { return 1; } else if (TermHelper.getStartDate(ct1) != null && TermHelper.getStartDate(ct2) == null) { @@ -54,7 +57,8 @@ public int compare(CanvasTerm ct1, CanvasTerm ct2) { } else if (TermHelper.getStartDate(ct1).after(TermHelper.getStartDate(ct2))) { return -1; } else { - return 0; + // if start dates are the same, return in ABC order + return ct1.getName().compareTo(ct2.getName()); } } diff --git a/src/main/resources/templates/fragments/termData.html b/src/main/resources/templates/fragments/termData.html index 6eaf7fe..37df2e6 100644 --- a/src/main/resources/templates/fragments/termData.html +++ b/src/main/resources/templates/fragments/termData.html @@ -40,7 +40,7 @@

(Active Term Name)

-
+

None available