TOC sub-branch inverse sorting?

Small question for anyone interested…

What’s the best way to sort sub-branches of a TOC by inverse created, without inversing the entire TOC?

I.e.

People
  John A. Doe (Farmer)
  John B. Doe (Theoretical Astrophysicist)
  ...
Journal Entries
  01-12-23 @ 01:45
  01-12-23 @ 01:40
  01-12-23 @ 01:35
  01-12-23 @ 01:30

My only current thought is sorting by something like list-order then using the reverse operator or subfilter maybe…?, but even that I am unsure how to implement :thinking:

There are some discussions taking place, about enhancing the TOC macros to this and other ends.

  • I have an idea based on ideas raised in other conversations recently.
  • I need to set up some test data and try something
    • Co incidentally I have some test data from a current experiment.

You may be aware you can click on a tag pill and drag and drop reorder, however this is a manual process.

  • When you do this it takes all tiddlers with that tag and sets them in the tag tiddlers list field, then dragging and dropping occurs on the list field.
  • Using the default TOC macros if a tag tiddler has the order in this list it will be used.

Here is a Journals tiddler which is tagging a few Journal tiddlers, in this case they contain the date stamp in the title so !sort[]] lists them in reverse chronological order. But you could just as well sort on another field.

  • Notice how if they are not in order you can use the button I created in Journals.
  • Try this on tiddlywiki.com

test-tiddlers.json (1.9 KB)

  • Note they are immediately sorted in the list within the Journals Tiddler but you need to press the button to sort them in the TOC
\function tag-list() [tag<currentTiddler>!sort[]format:titlelist[]join[ ]]
{{{ [enlist<tag-list>] }}}
<$button >
<$action-setfield $field=list $value=<<tag-list>>/>
Set sort order
</$button>

Futures;

  • When you create the tiddlers you tag with journals you could also generate the list and set the sort order if you have a button for this.
  • Perhaps I could add this feature to my reimagin tags?
  • We could compare the current list field with the new one and only show the button when they are not the same, perhaps even somehow automagicaly trigger the reordering.

This is definitely a functional solution, but I feel like having to use a button defeats the purpose of having the ability to sort TOC sub-branches.

I don’t know what a better solution would be, but it would be nice if the TOC macros took the sort orders of whatever they were listing without the need for a custom sort.

IE this group of tiddlers would be sorted alphabetically, this group of journal tiddlers would be sorted by inverse numerical because the journal parent group has a filter for it…

I think I am going to experiment with modifying the toc macros to maybe find a way to have full filters in the sort, that way you can do something like:

<<toc-selective-expandable 'TableOfContents' sort:'{{!!list-order}}'>>
list-order field for normal tiddlers:'[sort[]]'
list-order field for journal tiddlers:'[!sort[created]]'

Have a closer look at:

You should be able to use toc-filter in 1 branch on a “per branch” basis

Remember I said the above. That is where @pmario points to above.

That is what’s I suggested in my futures notes above and we have been working on in marios solution.

I haven’t had too much time to visit the TOC 2.0, metaphorically speaking, to play with how it works but giving it brief reads throughout my work day, I think it’ll be the solution to the question, but I will be taking a closer look to really see how it works soon enough.

Consider using my solution as a workaround for now, I plan to add a feature to my reimagine tags solution in the near future;

  • It provides tools on the tag pill dropdown, I would add a “re-sort” button, that commits a selected sort order into the list field, thus the toc will become that order.
  • In the long run @pmario’s solution would allow you to change parameters in the TOC macro’s and add a field to any tiddler to select the child filter including sort.
  • I can see value in making a core hack such that when you add/delete a tag, the list field is automatically updated to a desired sort order.
    • This way you do not even need to have a differently configured TOC

@pmario this is Another approach to TOC’s given they are based on tags, we add features to tag handling, in addition to the improved TOC macros

  • If a tag tiddler contains a sort-order or filter-field use that to list tiddlers in the tag pill
  • If adding or removing a tag and the tag tiddler has a “sort-order or filter-field” then commit this to the list-field.
    • A message catcher on tm-add-tag and tm-remove-tag could to this.
  • We could also automagicaly remove tags from tiddlers when a particular condition is true eg remove the todo tag if the todo item has the done tag.

I have long sought this feature I have called “smart tags”.

  • I could first implement it in my “filter pill” solution, if I create “filter pill tiddlers”.
  • Filter pill tiddlers could also be filters with $:/tags/Filter