When using 'path:' search operator sort the result by the full path rather than only the file name

Use case or problem

I have “TODO” subfolders in many places throughout the Vault. I use path:TODO/ search to aggregate the files in these subfolders into one list. Unfortunately the default sorting behavior does not take into consideration the full path, it only sorts by the file name (note’s title). This produces unorderly result.

Proposed solution

When path: operator is used and paths are displayed, sort the resulting list by the full path.

Current workaround (optional)


1 Like

Possible workaround

A workaround if you’re willing to use Dataview is to do something like:

WHERE contains(file.folder, "TODO")
SORT file.folder

Where you also could change the contains() to endswith() or startswith(), and/or adding slashes, /'s, here and there to further limit your search. If you want to see the folder in the result, you could change the first line to LIST file.folder

1 Like

Thanks, will give it a spin.

Ended up with this:

TABLE rows.file.link AS Task
WHERE contains(file.folder, "TODO")
GROUP BY file.folder AS Path
SORT file.folder
1 Like