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
master
Andrew P Maney 5 years ago committed by Tom Hacohen
parent 77f734a227
commit aa9e85a520

@ -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);

Loading…
Cancel
Save