From aa9e85a5202ebd7c71a4dc0c6dbeb64433954be4 Mon Sep 17 00:00:00 2001 From: Andrew P Maney Date: Sat, 4 Apr 2020 13:49:32 -0700 Subject: [PATCH] Tasks: fix priority sorting Priority sorting had some inconsistencies. The Infinity was causing tasks to not be sorted (Infinity - Infinity = NaN). Adding sortByDueDate also ensures better sorting when tasks have the same priority --- src/components/Tasks/TaskList.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Tasks/TaskList.tsx b/src/components/Tasks/TaskList.tsx index 73e3876..4690a6f 100644 --- a/src/components/Tasks/TaskList.tsx +++ b/src/components/Tasks/TaskList.tsx @@ -41,9 +41,9 @@ function sortDueDate(aIn: TaskType, bIn: TaskType) { } function sortPriority(aIn: TaskType, bIn: TaskType) { - // Intentionally converts 0/undefined to Infinity to sort to back of the list - const a = aIn.priority || Infinity; - const b = bIn.priority || Infinity; + // Intentionally converts 0/undefined to 10 (1 more than lowest priority) to sort to back of the list + const a = aIn.priority || 10; + const b = bIn.priority || 10; return a - b; } @@ -67,6 +67,7 @@ function getSortFunction(sortOrder: string) { break; case 'priority': sortFunctions.push(sortPriority); + sortFunctions.push(sortDueDate); break; case 'title': sortFunctions.push(sortTitle);