diff --git a/main.js b/main.js index 69b7f05..e437a02 100644 --- a/main.js +++ b/main.js @@ -270,6 +270,14 @@ class OrgTodoListView extends ItemView { return true; }); + // sort by due date - items with due dates first! + this.filtered.sort((a, b) => { + if (a.dueDate && b.dueDate) return a.dueDate.localeCompare(b.dueDate); + if (a.dueDate) return -1; // a has a date, b doesn't → a first + if (b.dueDate) return 1; // b has a date, a doesn't → b first + return 0; // neither has a date → keep as-is + }); + this.listEl.empty(); if (this.filtered.length === 0) {