Sort Dataview Grouped Elements by number of appending rows

What I’m trying to do

I have several cases where I retrieve a dataview table with grouped elements. In this case I let dataview display all “dead links” (for not-yet-existing notes) and also retrieve the array of notes that generate this link. (Code below)

What I would like to do now, is to sort the first row (which are the non-existing notes) depending on how many notes are linking to them in the second column, so that I can easily see, which notes are especially important to make.

TABLE rows.file.link AS Bezug 
FLATTEN file.outlinks AS OUT
WHERE !OUT.file AND !(contains(meta(OUT).path, "/"))
GROUP BY OUT AS Anzulegen

Things I have tried

I tried google/forum search and browsed the Dataview library, but couldn’t find helpful information whether this is possible. I think there might be an option to retrieve the number alue of the connected notes-array by JS (no?) but I do not know JS and am not sure this can be applied as a sorting method to the first main column.

To clarify what I mean, here an (unordered) example table as retrieved by the dataview code:

non existing note files that link to it
note 1 -a
-b
note 2 -c
note 3 -a
-c
-y

You could try the following:

```dataview
TABLE rows.file.link AS Bezug 
FLATTEN file.outlinks AS OUT
WHERE !OUT.file AND !(contains(meta(OUT).path, "/"))
GROUP BY OUT AS Anzulegen
SORT length(rows) desc, key
```

This should sort by the number in each group, and then by key if the number is equal.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.