Skip to content

Commit

Permalink
Change default comparator to original order
Browse files Browse the repository at this point in the history
  • Loading branch information
solomonng2001 committed Apr 2, 2024
1 parent f307fbe commit 2285fc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package seedu.address.model.person;

import static seedu.address.model.Model.COMPARATOR_SHOW_ORIGINAL_ORDER;

import java.util.Comparator;

/**
Expand Down Expand Up @@ -41,7 +43,7 @@ public static Comparator<Person> getComparator(SortCriteria sortCriteria, SortOr
comparator = Comparator.comparing(Person::getSchedule);
break;
default:
return Comparator.comparing(Person::getName);
return COMPARATOR_SHOW_ORIGINAL_ORDER;
}
if (sortOrder == SortOrder.DESC) {
return comparator.reversed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public void getComparator() {
// sort by invalid or default criteria
Comparator<Person> invalidAscComparator = PersonComparator.getComparator(SortCriteria.INVALID, SortOrder.ASC);
// ascending
assertTrue(invalidAscComparator.compare(alice, bob) < 0);
assertTrue(invalidAscComparator.compare(alice, bob) == 0);
assertEquals(0, invalidAscComparator.compare(alice, aliceCopy));
// descending
assertTrue(invalidAscComparator.compare(alice, bob) < 0);
assertTrue(invalidAscComparator.compare(alice, bob) == 0);
assertEquals(0, invalidAscComparator.compare(alice, aliceCopy));
}
}

0 comments on commit 2285fc1

Please sign in to comment.