Hierarchical sorting

124 views
Skip to first unread message

Michael Wiktowy

unread,
Apr 19, 2021, 8:56:08 AM4/19/21
to TiddlyWiki

Question for those more savvy with using filter/subfilter/subsort operators:

I have a hierarchy of tiddlers tagged with their parent tiddlers, for example:
A
|A.1
||A.1.a
||A.1.b
...
|A.2
||A.2.a
||A.2.b
...
|A.3
B
|B.1
||B.1.a
||B.1.b
...
|B.2
... etc.

Typically, I would list the tree via nested recursive list something like:
\define recursive_list()
<$list filter="[<sec>tagging[]] +[sortan[]]" variable="sec">
<$list filter="[tag<sec>...]/>
<<recursive_list>>
</$list>
\end

Then initialize the "sec" variable via a list/set/var widget and call the recursive_list macro.

I wanted to use the Shiraz dynamic tables to display this list but it takes a single filter parameter. I could hack up the dynamic tables and try to piece together the table body within this list structure record by record. But before I try to figure out how to do that, I was wondering if anyone had an elegant single filter that could handle this. I saw the conversation here: https://groups.google.com/g/tiddlywiki/c/ws05-YAtJ7k/m/jz9JIe9zDQAJ
so maybe it is not possible to recurse within a single filter.

I could use the kin operator to gather all the relevant tiddlers but how would I sort the children such that they are after the parents without having to manually assign some sort of order field?

Has anyone else solved this problem in a better way?

/Mike

TW Tones

unread,
Apr 20, 2021, 1:55:19 AM4/20/21
to TiddlyWiki
Mike,

Without being sure, perhaps the sortsub feature in the latest release could help you define a single filter to feed into the table filter?

Recursion does not demand a single filter, just your use case, but I understand the problem. 

The worst case is to generate a table in a tiddler, or tiddlers with the same tag that the table uses if you can't combine the logic.

Tones

Reply all
Reply to author
Forward
0 new messages