Skip to content

Commit

Permalink
SAK-33890 Update EnrollmentDecorator.java (sakaiproject#5332)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinmarques authored and ottenhoff committed Feb 23, 2018
1 parent cfd749a commit 13230d5
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import java.io.Serializable;
import java.util.Comparator;
import java.util.Map;
import java.text.Collator;

import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.sakaiproject.section.api.coursemanagement.CourseSection;
import org.sakaiproject.section.api.coursemanagement.EnrollmentRecord;
import org.sakaiproject.section.api.coursemanagement.User;
Expand All @@ -52,8 +53,15 @@ public EnrollmentDecorator(EnrollmentRecord enrollment, Map categoryToSectionMap

public static final Comparator<EnrollmentDecorator> getNameComparator(final boolean sortAscending) {
return new Comparator<EnrollmentDecorator>() {
private final Collator collator = Collator.getInstance();
private int compareUsers(final User u1, final User u2) {
this.collator.setStrength(Collator.PRIMARY);
return new CompareToBuilder()
.append(u1.getSortName(), u2.getSortName(), this.collator)
.toComparison();
}
public int compare(EnrollmentDecorator enr1, EnrollmentDecorator enr2) {
int comparison = enr1.getUser().getSortName().compareTo(enr2.getUser().getSortName());
int comparison = compareUsers(enr1.getUser(), enr2.getUser());
return sortAscending ? comparison : (-1 * comparison);
}
};
Expand Down

0 comments on commit 13230d5

Please sign in to comment.