Dataview not sorting tasks correctly

Things I have tried

dv.taskList(dv.pages('!"Templates"').file.tasks.where(t => !t.completed).sort(f => f.day, 'desc'))

What I’m trying to do

I want to get a sorted list of tasks, with the most recent at the top. The list isn’t sorting correctly. It used to, until the last dataview update.

I now get an incorrectly sorted list. Here’s a link to an image showing the problem

You can see that the files containing tasks aren’t in sorted order. It shows:

  • 2022-06-01-Wed
  • 2022-05-06-Fri
  • 2022-05-18-Wed
  • 2022-05-25-Wed

The links in May this year are in ascending order, not descending order.

The date format I’ve got in my dataview config is yyyy-mm-dd-EEE.

I haven’t changed any config data — this just started to appear when I updated the obsidian plugins.

I can’t exactly replicate your behavior: I get pure ascending order with that query (my filenames do have slightly different date format). What I think is happening, at least for me, is that the groupByFile is default to true for dv.taskList link to documentation and I don’t see a way to convince that to sort in desc. So instead I set it to false and did my own groupBy, manually sorting the group keys in descending order afterwards. Does this work with your date format?

dv.taskList(dv.pages('!"Templates"').file.tasks
.where(t => !t.completed).groupBy(t => dv.fileLink(t.path))
.sort(t => t.key, 'desc'), false);

Given there are several recent issues and discussion threads about tasks over at the dataview GitHub, this use case for sorting the groups in reverse might be worth mentioning over there as well?

No, doesn’t work. Same result.

1 Like

Well, that’s confusing! :frowning:
Are you on version 0.5.34 for Dataview? There have been a lot of updates recently. If there was an update, does your original query from the top of the thread produce the same behavior after the update? If you were already on the current version, maybe check out the Issues and Discussions tabs on the dataview GitHub project and see if anyone there has posted anything similar.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.