From 6a376af5721be9f62079eb167775f5556e0b8740 Mon Sep 17 00:00:00 2001 From: Rostyslav Hnatyshyn Date: Tue, 16 Jun 2026 22:10:01 -0700 Subject: [PATCH] sort by due date, items with due dates come first --- main.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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) {