SORTing a table list with leading "The "s being ignored

What I’m trying to do

I’m writing a Dataview script to SORT a table list of Movies but I want to remove the leading "The "s from the sort. So “The ABC Movie” would appear in the list adjacent to “ABC Movie”. I don’t want to alter the md files for these movies, and I don’t want to say add the “, The” to the end of the title. I just want the sort to ignore the leading "The "s and sort by the remaining portion of the title. If there is no leading "The " then the title would sort normally. The Title of the movie is the

I’ve tried a couple coding AIs but they don’t seem to know Dataview well.

This shouldn’t be this difficult.

Current script:

WHERE contains(, "(Movie)")
SORT Title asc

Nope, so this is untested:

WHERE contains(, "(Movie)")
SORT regexreplace(Title, "^The ", "") asc

Exactly what I wanted, thank you. Tell all your friends that you are smarter than the AIs. At least at Dataview, at least for now.

The AIs came close but didn’t know the regexrepalce command. They were trying to use .sortby and .ltrim commands. Which I’m not even sure are dataview commands.

They’re not Dataview functions, see list of functions to use in standard query for a better list and references than the AI’s.

1 Like

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