TOC - more than one critera possible?

Hello forum,

This sorting works fine:

<div class="tc-table-of-contents">
<<toc-selective-expandable 'HelloThere' 'sortan[]'>>
</div>

If I choose this sort - field dosen’t exist - it looks like it is sorted on created date/time:

Is it possible to have a cascaded sort like !sort[published] and than sortan[]?
(published is a custom date field, filled with eg. 2021.10.05)

Thanks
Stefan

Something like group-by[] – perhaps that could be a second param to the sort operators?

Sortan[] sorts, by default, the alpha-numerical value of the TITLE of the input tiddlers. Since you don’t provide a field name, they are sorted by title, alpha-numerically.

So the first question is, what did you want sortan to do ?

For performing compound sorts, there is the sortsub operator. .

A compound sort where one element is inverted might be tricky, though.

@Mark_S Thanks for feedback.

I’m asking for a combination of sort in TOC:
1. sort by individual date field (=published) in descending order and
2. sort by title.

When a tiddler has no published field, it should sort by title.
I think, sortsub won’t do it…

This seems to do what you ask for, as I understand it. Notice in the example below that I’ve put the published date in the title so you can see what’s happening. Tiddlers with publication dates get sorted by inverse publication dates. Tiddlers without publication dates get sorted after that by title.

This depends on you following a strict format for the publication date (i.e. month, day are zero-padded).

<$vars mysubsort='[{!!published}split[.]!is[blank]join[]subtract[99999999]negate[]else[99999999]] +[addsuffix{!!title}]'>

<div class="tc-table-of-contents">
<<toc-selective-expandable 'HelloThere' 'sortsub<mysubsort>'>>
</div>

</$vars>

image

1 Like

@Mark_S Amazing!
Thanks a lot - that’s exactly, what I want!

Greetings
Stefan

1 Like