I am using a Dataview query to display all the notes which have a YAML field called “area”, and the value of that field is a link to the current note.
I am then grouping those notes using the “realm” field.
Right now, the groups are sorted in alphabetical order.
I would like them to be sorted in a custom order.
dataview
TABLE
rows.file.link AS "Name",
rows.type AS "Type"
FROM -"Templates"
WHERE contains(area, this.file.link)
SORT file.name ASC
GROUP BY realm
Hi.
In DQL queries you need to “construct” the wanted sort manually.
For example:
Wanted order: Literature, Math, Languages, Drawing, Tech, Personal
DV command: use function `choice()` to define the wanted order
Querie:
```dataview
TABLE
rows.file.link AS "Name",
rows.type AS "Type"
FROM -"Templates"
WHERE contains(area, this.file.link)
SORT file.name ASC
GROUP BY realm
SORT choice(realm = "Literature", "1",
choice(realm = "Math", "2",
choice(realm = "Languages", "3",
choice(realm = "Drawing", "4",
choice(realm = "Tech", "5",
choice(realm = "Personal", "6", "other"))))))
```