obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

FR: Order the elements of row array in GroupBy tables according to SORT

Open Cammagno opened this issue 3 years ago • 8 comments

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

Cammagno avatar Mar 22 '22 14:03 Cammagno

Sort the rows in the desired order before grouping - they should then be sorted correctly.

blacksmithgu avatar Mar 22 '22 23:03 blacksmithgu

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.

Cammagno avatar Mar 23 '22 00:03 Cammagno

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.

blacksmithgu avatar Mar 24 '22 05:03 blacksmithgu

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?

frankreporting avatar Jun 29 '22 20:06 frankreporting

Sorting before a group should sort values inside the GROUP BY; sorting after a group sorts the groups.

blacksmithgu avatar Jun 30 '22 04:06 blacksmithgu

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?

frankreporting avatar Jun 30 '22 17:06 frankreporting

Do another sort text before the group by.

AB1908 avatar Jun 30 '22 21:06 AB1908

I think this may be a bug on my part. Let me check.

blacksmithgu avatar Jun 30 '22 21:06 blacksmithgu