Skip to content

Commit

Permalink
Updated UniquePersonList
Browse files Browse the repository at this point in the history
  • Loading branch information
Woonhian committed Oct 13, 2018
1 parent fc2cb12 commit 54437d9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void sortBy(String field, String order) throws NoEmployeeException {
/**
* Used to sort by name
*/
class sortByName implements Comparator<Person> {
Comparator<Person> nameComparator = new Comparator<Person>() {
@Override
public int compare(Person p1, Person p2) {
return p1.getName().fullName.compareTo(p2.getName().fullName);
Expand All @@ -130,7 +130,7 @@ public int compare(Person p1, Person p2) {
/**
* Used to sort by department
*/
class sortByDepartment implements Comparator<Person> {
Comparator<Person> departmentComparator = new Comparator<Person>() {
@Override
public int compare(Person p1, Person p2) {
return p1.getDepartment().fullDepartment.compareTo(p2.getDepartment().fullDepartment);
Expand All @@ -139,11 +139,11 @@ public int compare(Person p1, Person p2) {

switch (field) {
case "name":
comparator = new sortByName();
comparator = nameComparator;
break;

case "department":
comparator = new sortByDepartment();
comparator = departmentComparator;
break;

default:
Expand Down

0 comments on commit 54437d9

Please sign in to comment.