aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/encora/ToDosRepository.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/encora/ToDosRepository.java')
-rw-r--r--src/main/java/com/encora/ToDosRepository.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/com/encora/ToDosRepository.java b/src/main/java/com/encora/ToDosRepository.java
index a4c9a10..c4bdcba 100644
--- a/src/main/java/com/encora/ToDosRepository.java
+++ b/src/main/java/com/encora/ToDosRepository.java
@@ -171,7 +171,7 @@ public class ToDosRepository implements JpaRepository<ToDos, Integer> {
break;
case "DueDate":
- comparator = Comparator.comparing(ToDos::getDueDate);
+ comparator = Comparator.comparing(ToDos::getDueDate, Comparator.nullsLast(Comparator.naturalOrder()));
break;
default:
@@ -187,16 +187,20 @@ public class ToDosRepository implements JpaRepository<ToDos, Integer> {
// Filter and then sort all of our to dos.
public void refreshFilteredToDos(Sort sort, String name, String priority, String done) throws Exception {
- this.filteredToDos = this.findAllWithFilter(name, priority, done);
-
try {
Comparator<ToDos> comparator = this.getToDoComparator(sort);
- Collections.sort(this.filteredToDos, comparator);
+
+ this.filteredToDos = this.findAllWithFilter(name, priority, done);
+ this.filteredToDos.sort(comparator);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
+ public List<ToDos> getFilteredToDos() {
+ return this.filteredToDos;
+ }
+
/*
* N O T Y E T D E F I N E D .
*/