How to keep Journal tiddlers always sorted by title in descending order?

My Journal tiddlers have title in this format YYYY-0MM-0DD. Now I can add a button to sort the “Journal”. There are helpful guides for sorting, like Sort tags by color.

Problem is how do I make sure the “Journal” tiddlers are always sorted without me having to click on any button. How do I go about it?

One way is to trigger “Journal” sort after any tiddler is saved.

  1. Is there a way to listen for save event?
  2. Or override save action?

Normaly we would sort in a list widget. In your case the title can be sorted so you may use the filter [tag[Journal]sort[title]] or !sort.

  • however your question includes more details I think you want something else.

Could you explain it a little more?

Scenario 1

Well, say I am editing today’s journal, and I need to edit the journal entry of the day before yesterday. How do I get to the “day before yesterday” journal?

I click on the journal tag and click the “sort button” to sort entries in descending order. (I have a custom button in the tag pill dropdown that lets me sort entries.) Then I pick the entry I am looking for, which is now more accessible because of sorted entries.

Scenario 2

Another use case is adding 'Next" and “Previous” links to the bottom of the very tiddler. (There are guides on it. No big deal here.) But these buttons pick the next/previous entry from the list field.

If the list field gets automatically sorted, then the Next/Previous buttons will work as expected.

Side Note

If journals are titled in this format, YYYY-0MM-0DD, they are easier to sort.

3 Likes

I can give you more later, I must run to an appointment.

  • personally I modified the new Journal buttons to include a tiddlywiki date/time stamp in the field journal-date, then I don’t care what the title is as I sort by journal-date or not journal date [tag[journal]!sort[journal-date]]
1 Like

Could you write a macro that performs a filter like this:

[tag[journal]compare:string:gt[$date$]limit[1]sort[title]]

where $date$ is the date or tiddler title of the current tiddler. This filter would return the tiddler of the next tiddler. You could do something similar for a previous button.

I’d think you’d want to add logic to disable the button when this filter returns an empty result set.

Thanks for this–I could use this too!

Craig

1 Like

That’s a good idea. This way I will not have to worry about the journal tiddlers’ title format.

Thanks @clsturgeon. Using gt, I can solve the problem 2.

I was toying with the idea of using arithmetic operations to calculate next and previous dates, but your gt is more straightforward.


But is this not possible? If I can listen to the save event, then I can trigger a “sort operation” on every save.