Dataview query help, sorted list from file properties

What I’m trying to do

I have 2 folders (@Episodes & Episode List). They have files with the same names. The file in the @Episodes folder has a bunch of properties, many of which are list type.

I’m trying to create tables in the file of the same name in the Episode List folder with the properties from the file from the @Episodes folder. Importantly, each item in the property list is a link (ie [[Character Name]])

Then I want to combine all the records from all the files in the @Episodes folder into one deduplicated, alphabetized table.

Example:

@Episodes/Episode01.md

Characters:

  • [[Trent]]
  • [[Andi]]
  • [[Betty]]

@Episodes/Episode02.md

Characters:

  • [[Andi]]
  • [[Dionne]]

End result:

Episode List/Episode01.md

Characters (3)

\[\[Andi\]\]

\[\[Betty\]\]

\[\[Trent\]\]

Episode List/Episode02.md

Characters (2)

\[\[Andi\]\]

\[\[Dionne\]\]

And then a file with:

Characters (4)

[[Andi]]

[[Betty]]

[[Dionne]]

[[Trent]]

Things I have tried

Here are the queries I’ve tried for the individual files.

```dataview

TABLE without id

Characters

FROM

@Episodes

WHERE file.name = this.file.name AND

reverse(split(file.folder, “/”))[0] = reverse(split(this.file.folder, “/”))[0]

SORT Characters

```

```dataview

TABLE

FROM

@Episodes

WHERE file.name = this.file.name AND

reverse(split(file.folder, “/”))[0] = reverse(split(this.file.folder, “/”))[0]

FLATTEN nonnull(Characters) AS CHARACTERS

GROUP BY CHARACTERS

```

These both work ok, but for some reason, they don’t actually sort in alphabetical order. Note that this seems to only be a problem when the list is made up of links…?

And here’s my similar query for the combined list, which has the same problem of sorting not working:

```dataview

TABLE

FROM “@Episodes/Tale 7”

FLATTEN nonnull(characters) as Characters

GROUP BY Characters

SORT Characters

```

If you don’t believe me, here’s a screenshot of the result of the query above, decidedly not alphabetized.