Sorting in a tabbed toc: getting the syntax right

I love the toc-tabbed-external-nav macro, and rely on it regularly. But I can’t find any way of specifying a sort order. (Presumably this also applies to the toc-tabbed-internal-nav also.)

This matters, because relying on the tag’s list field (the default way to determine the sort order for a tabbed toc) is unmanageable when:

  • the number of tagged tiddlers is large
  • the needed ordering might need to change dynamically (say, to !sort[modified])
  • the needed ordering relies on details that aren’t recognizable at the title level.

It also matters because the documentation (as it stands) is confusing on this point:

To wit: The Table-of-Contents Macros tiddler at tiddlywiki.com implies that tag and sort parameters apply to ALL toc macros, and that the tabbed versions also have “additional” parameters. If in fact the sort parameter is NOT available within the tabbed toc styles, then the documentation should at least be fixed to make this clear.

What can be done?

Of course, my preference is (1) to learn that I’m wrong, and that I just have yet to grok the required syntax for specifying sort order within a tabbed toc, or (2) to hear agreement that this is a missing feature that can and should be fixed. (IIRC, something like that did already happen around allowing for an “exclude” variable to carve out exceptions to the tag-based parameter built into the tabbed toc.) Only at preference level (3): change the documentation to reflect the disappointing truth.

Did you try the examples? Adding the “sort=”!sort[modified]" should do what you want.

<$macrocall
	$name="toc-tabbed-internal-nav"
	tag="TableOfContents"
    sort="!sort[modified]"
	selectedTiddler="$:/temp/toc/selectedTiddler"
	unselectedText="<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
	missingText="<p>Missing tiddler.</p>"
/>
1 Like

Can you share an example that works on Tiddlywiki.com and a desired alternativew sort order.

  • On Table-of-Contents Macros it mentions the sort parameter.
  • It is in the definition of \define toc-tabbed-external-nav(tag,sort:"",...

I think I know the issue

The sort parameter is a subfilter of the old fashioned type where it is in a filter like this $sort$.

So when using the sort parameter use sort="!sort[modified]"

1 Like

I thought I had tried every variation on that theme, but apparently had not.

(I think I just tried sort=“modified” and didn’t expect to re-use the word ‘sort’ within the value for the sort parameter)