How to sort grouped obsidian dataview tasks by modification time of the pages they are in

1.1k views Asked by At

The code below finds and groups relevant tasks from my vault nicely, but the list is alphabetically ordered (by the name of the page in which the tasks are located.

dv.taskList(
    dv.pages('-#exclude').file.tasks
    .where(t => !t.completed)
);

How can I sort grouped obsidian dataview tasks by mtime of the document they are in, so that if I edit a document, that heading and all tasks in the document are moved to the top of the list?

I have tried adjusting the code like this, but it doesn't do anything:

dv.taskList(
  dv.pages('-#exclude').file.tasks
    .where(t => !t.completed)
    .groupBy(t => t.key)
    .sort(t => dv.page(t.key).file.mtime, 'asc'),
  false
);
0

There are 0 answers