obsidian-dataview
obsidian-dataview copied to clipboard
FR: Order the elements of row array in GroupBy tables according to SORT
In a GroupBy table, the elements of the row array seem to be chronologically ordered (putting the last-edited last). see discussion here
Is it possible to order them by SORT instead? Also because as it is now, SORT seems to be useless, in such tables
Sort the rows in the desired order before grouping - they should then be sorted correctly.
Sort the rows in the desired order before grouping - they should then be sorted correctly.
Ok, so:
- if in the query the GROUP BY line comes before the SORT line, it puts the more recent edited note last.
- if the SORT line is before the GROUP BY line, it keeps the sort order.
When you use GROUP BY, it is changing how the data looks - your query then operates on groups and not on individual pages. So if you GROUP BY .. SORT, you are sorting the groups by a nonexistent value and not the pages in the groups. The pages being in "most recent edited last" just happens to be Dataview's default sort order.
This could probably be made more clear with documentation that better explains Dataview's stream-based processing model.
So does this mean that effectively you cannot currently control the order that groups are rendered, i.e. if you group tasks by file name, you can only ever list the files (groups) in alphabetical order, and not, say, in reverse alphabetical?
Sorting before a group should sort values inside the GROUP BY; sorting after a group sorts the groups.
So given file names like 2022-05-05 This is a file I should be able to do something like this:
task
from "00 Meta/06 Logbook"
where !completed
group by file.link
sort file.link desc
But it still lists the groups in ascending alphanumeric order. Example:
2021-08-18 Editorial Meetings
- [ ] task 1
- [ ] task 2
2021-08-19 Editorial Meetings
- [ ] task 3
Not sure what I'm missing? Does it only work in dataviewjs?
Do another sort text before the group by.
I think this may be a bug on my part. Let me check.