A/an/the and sorting

103 views
Skip to first unread message

PS

unread,
Mar 20, 2020, 10:46:39 AM3/20/20
to TiddlyWiki
Is there a good way to use the list-before or list-after field to allow sorting of tiddlers that ignores a/an/the at the beginning of titles?

For example, I was thinking the way it worked would allow you to put "Bell Jar" for the list-after field of a tiddler called "The Bell Jar", and then as long as I didn't specify sort[title], it would put The Bell Jar in place after the imaginary tiddler "Bell Jar" and sort anything without one of those fields in the straightforward alphabetic way. But it turns out that the tiddler in list-after or list-before has to actually exist, I guess? At least, it only works if, say, I tell it to list after "Bag of Bones", which does exist. But what if I make a tiddler called Beatrix, which ought to be in between? Now I have to remember to go back into The Bell Jar and update the sorting again, which could get very tedious and is prone to error.

Please tell me there's a good way to handle sorting with a/an/the, even a different method, short of going the old route of tacking the offending article back on to the end!

Right now, the only other thing I can think of is creating a new field on every single tiddler I'd want to sort as an alternate title field to use when sorting, and I'd rather avoid that.

PMario

unread,
Mar 20, 2020, 12:04:43 PM3/20/20
to TiddlyWiki
Hi,

You should have a closer look at this GitHub discussion: https://github.com/Jermolene/TiddlyWiki5/issues/4394

-m

PS

unread,
Mar 20, 2020, 12:21:35 PM3/20/20
to TiddlyWiki
Hi there, thanks. So, what I can glean from that link is that maybe in the future a new sort operator will be able to do what I want? That's very good; I hope it makes it in soon.

As it stands, is there a way to do this currently without adding a bunch of work for myself? Especially if said work will become unnecessary and inefficient in the future. Ideally, I'd prefer a solution which was just a matter of dealing with only the tiddlers that have an article at the beginning, because going back and fixing just those would be easier than fixing every tiddler I'd like to sort or every instance where I've sorted something. Currently I'm going the "Bell Jar, The" route but not totally satisfied with it.

I notice you commented on that discussion as well--is there a temporary solution you've settled on for your own purposes?

Mark S.

unread,
Mar 20, 2020, 12:28:29 PM3/20/20
to TiddlyWiki
This can do it for standard A/An/The and as long as you don't mind that no title can have === in it. You can pick some other unique set of characters if you're careful.


\define titleprep()
<$vars lb="[[" rb="]]">
<$list filter="[tag[mysort]]" >
<$list filter="[all[current]splitregexp[^The\s]splitregexp[^A\s]splitregexp[^An\s]!is[blank]]" variable="fixedtitle">
<<lb>><<fixedtitle>>===<<currentTiddler>><<rb>><br/>
</$list>
</
$list>
</$vars>
\end

<$wikify text=<<titleprep>> name=sortedtitles>
<$list filter="[enlist<sortedtitles>sort[]splitregexp[===.*]]">

</
$list>
</$wikify>

Here's my example of before and after (screenshot should show here) :




Message has been deleted

PS

unread,
Mar 20, 2020, 1:47:31 PM3/20/20
to TiddlyWiki
Thanks, everyone, for responding. I struggle with the more technical side of TiddlyWiki, but so far wrangling it has felt worthwhile. Good to know that I should steer clear of list-before/-after for this purpose. I was looking for any tool that might do the job and am not clear on best practice.

Mark, I'm intrigued by your post as a beginner and will have to take some time to figure out what each part actually does. It certainly reminds me that I should learn how to use regular expressions. Avoiding "===" is not a problem! And then I suppose one could set up redirects like Wikipedia has to send the missing Bell Jar tiddler on to The Bell Jar? (Or transclusion?) My issue, though, is that I wish one thing could be used for sorting (Bell Jar) and another returned for display (The Bell Jar). Displaying "Bell Jar" is functionally pretty similar to naming the tiddler "Bell Jar" when it comes to all my lists.

Mat, your post was deleted as I was responding, but here was what I had typed: Mat, that's an interesting solution! But I can't seem to get it to work? It actually seems to do the inverse--it sorts as if the "The" was present, but displays "Bell Jar". For example, I tested just a small selection of titles, two with an initial "The", and the resulting list appeared in this order: Bag of Bones, Beatrix, Tales from Earthsea, Bell Jar, Tempest, Treasure Island. (Am I using the filter incorrectly? My filter was just based on a temporary tag, so all it is, is filter="[tag[book1]]".)

I'm willing to accept that perhaps TiddlyWiki doesn't yet have the functionality I want, but either way, I appreciate the look at different ways to problem-solve.

Also, would it be worthwhile to join Github and chime in with some support for the feature on that thread? I don't know if it's meant mostly for technical suggestions and solutions, or if a simple confirmation that another person would find such a feature useful is... useful.

PMario

unread,
Mar 20, 2020, 2:05:58 PM3/20/20
to TiddlyWiki
On Friday, March 20, 2020 at 6:47:31 PM UTC+1, PS wrote:
...
Also, would it be worthwhile to join Github and chime in with some support for the feature on that thread? I don't know if it's meant mostly for technical suggestions and solutions, or if a simple confirmation that another person would find such a feature useful is... useful.

I think it's worth to use your GitHub account, or make one, to "Star" the tiddlywiki repo. The more stars ... the better ;)


And once you have an account, you can start to join discussions there too, if you want.

TW-issues should be "solvable". So if you start your suggestion with:



As a User I would like to: ... or

The existing behaviour is: ....
The expected behaviour is: ...


If it looks like this, we have chance, to do something. ... BUT ... Be aware "The core" (devs) have to have "the big picture" in mind.
So not everything, which "sounds" great for 1 user may work for all users.

have fun!
mario

Mark S.

unread,
Mar 20, 2020, 2:43:02 PM3/20/20
to tiddl...@googlegroups.com
By "redirects" I assume you meant links? Yes, I could have added it with a few more minutes.

Actually, the easiest way to deal with the situation is to create a "sortby", "caption", or "descriptoin" field. That field could in turn be populated by a button that you would activate whenever you want to see a "report" of your titles.This not only covers the "obvious" situations where a title starts with A/An/The, but others where you might want it to sort by something entirely different. Like you might want to sort "Suicide is Painless" as "M.A.S.H. Theme song".

I don't think a sort-without-articles is a standard tool in most programming APIs. So you might as well find a good solution and settle in.

EDIT: Hmm, looks like work is actually happening with it. That would be cool.

Mat

unread,
Mar 20, 2020, 2:56:18 PM3/20/20
to TiddlyWiki
PS wrote:
Mat, your post was deleted

Yes, I deleted it because I noted that you wrote: "Right now, the only other thing I can think of is creating a new field on every single tiddler I'd want to sort as an alternate title field to use when sorting, and I'd rather avoid that."
...and my solution did, indeed, require that you add a field for everyone title that you wish to display differently.
If you, in spite of this, are positive to do this, I'll reply to the reply you just made.

<:-)

PS

unread,
Mar 20, 2020, 8:22:51 PM3/20/20
to TiddlyWiki
Actually, it worked perfectly, Mat! I don't mind adding fields to the ones I need to be different--I just didn't want to add fields to the ones I wanted to stay the same, too! I thought perhaps I would need to, not realizing you could have it use another field if that was empty. I swapped the tiddler title and sorting titles, realizing my mistake (I mistook the additional field as the sorting title, not display), and after refreshing the TiddlyWiki it worked. Now my list is perfectly alphabetized and displayed in my sidebar. I may leave some of the other lists as-is for the time being (I'm still using list-links in many places) but I'm pleased to have a proper display for navigation. I'll post that code again in case someone else finds this topic while searching for help:
<$list filter="[tag[book1]]">

<$transclude field=nick>
  <$transclude field=title/>
</$transclude>
</$list>


Mark, I agree with your point about planning for less standard sorting conditions! If you don't mind and have the time, would you be willing to break down your example's components a bit? You don't have to get very specific, but I'm interested in knowing how it works and there's quite a few nested pieces.

And noted, Mario! I will check out Github more for sure, though likely as a silent observer!

Mat

unread,
Mar 20, 2020, 10:34:05 PM3/20/20
to TiddlyWiki
PS wrote:
Actually, it worked perfectly, Mat! 

Good to hear. Case solved then, I take it.

<:-)

Mark S.

unread,
Mar 20, 2020, 11:20:50 PM3/20/20
to TiddlyWiki
Here's another technique that doesn't need wikify nor a macro. It does still need a special indicator to "store" the original prefix:

<$list filter="
[tag[mysort]removeprefix[The ]addsuffix[===The]]
[tag[mysort]removeprefix[A ]addsuffix[===A]]
[tag[mysort]removeprefix[An ]addsuffix[===An]]
[tag[mysort]!prefix[A ]!prefix[An ]!prefix[The]]
+[sort[]]
"
variable="fixedtitle" >
<$list filter="[
<fixedtitle>regexp[===]]">
<$list filter="[
<fixedtitle>split[===]nth[1]]" variable=end><$list filter="[<fixedtitle>split[===]nth[2]]" variable=start>
<$link to={{{ [
<start>addsuffix[ ]addsuffix<end>] }}}><<start>> <<end>></$link><br/>
</$list>
</$list>
</$list>
<$list filter="[
<fixedtitle>!regexp[===]]" variable="title">
{{{ [
<title>] }}}<br/>
</$list>
</$list>



On Friday, March 20, 2020 at 7:46:39 AM UTC-7, PS wrote:
Reply all
Reply to author
Forward
0 new messages