Tip: Removing "The" from titles in a sorted list

119 views
Skip to first unread message

Jeremy Ruston

unread,
Nov 17, 2020, 12:28:54 PM11/17/20
to TiddlyWiki Group
One of my personal TiddlyWiki’s contains song lyrics and chords, with the default tiddler displaying a list of the songs sorted by title. It’s been annoying for a long time that the titles starting “The …” are sorted under “T”, and not the first letter of the following word.

The new sortsub operator in v5.1.23 has provided a simple means to resolve things:

\define sort-filter() [<currentTiddler>removeprefix[the ]] ~[<currentTiddler>removeprefix[The ]] ~[<currentTiddler>]

<$list filter="[tag[song]sortsub<sort-filter>]" template="$:/_SongItemTemplate"/>

The subfilter relies on the fact that the removeprefix operator doesn’t return anything if the input string doesn’t start with the specified prefix. Thus we can step through the prefixes we want to remove, finishing up with the original title.

A more complete version should perhaps strip the prefix “A ”  as well.

It would be nicer if we have a case-insensitive version of removeprefix.

Best wishes

Jeremy

History Buff

unread,
Nov 17, 2020, 1:27:33 PM11/17/20
to TiddlyWiki
Thanks for pointing that out Jeremy. I have an immediate use for this and am anxiously waiting for the 5.1.23 release!

Damon

TiddlyTweeter

unread,
Nov 18, 2020, 5:03:13 AM11/18/20
to TiddlyWiki
Ciao Jeremy

That is useful!

For instance I maintain a large set of movies and Title sort previously involved a more complex workaround for correct Title sort order.
This will simplify things a lot!

Just FYI I need to discard these types of definite & indefinite articles ...

The, A, An, Die, Der, Das, Il, Ein, Eine, Lo, Le, La, Gli, L' etc etc

Thanks
TT 
Reply all
Reply to author
Forward
0 new messages