Given notes `Project A`

and `Project B`

which both contain these lines:

```
---
tags: project
---
* [ ] Task 1 [priority:: 2]
* [ ] Task 2 [priority:: 1]
```

Is it possible to construct a DQL (ideally not DataviewJS) query which will group the tasks by note and sort the groups and tasks independently, for example to yield:

Project A

- [ ] Task 2
- [ ] Task 1
Project B

- [ ] Task 2
- [ ] Task 1

The following query sorts the groups (notes) correctly, but fails to sort the tasks by the value of `priority`

, which makes sense because `SORT`

is acting on the products of `GROUP BY`

:

```
TASK
FROM
#project
GROUP BY
file.link as foo
SORT
foo ASC,
rows.priority ASC
```

In this post, @mnvwvnm suggests concatenating the two sort criteria in the `GROUP BY`

expression, for example like this:

```
GROUP BY
(file.link + " - " + priority) as foo
SORT
foo ASC
```

which yields:

Project A - 1

- [ ] Task 2
Project A - 2

- [ ] Task 1
Project B - 1

- [ ] Task 2
Project B - 2

- [ ] Task 1

This is very close to the desired output above, but cluttered, and wouldn’t do in the case of other sort criteria (e.g. if the notes were sorted by `mtime`

).