Sort on dates when date field blank

I am listing tiddlers using +[sort[created]] and/or +[!sort[created]] however amongst the tiddlers listed, is one or more missing tiddler titles, this means there is no created field and the empty field is resulting in the missing tiddler being represented as the oldest item, while not yet being created, an empty created field implies it remains to be created in the future, or be the youngest, not the oldest.

  • If you know a work around please tell me.
  • For now I think I may exclude missing tiddlers and list them separately.

Could this be considered a bug?, although to maintain backward compatibility perhaps we should be able to switch blank values as being high values rather than low values?

  • Perhaps an additional parameter on the various sort operators +[sort[created],[emptyHigh]] where the default is +[sort[created],[emptyHigh]] and can be left out +[sort[created]] as this is the current behaviour.
  • I have not investigated each of the other sorts and these may by definition have different defaults.

Other;
Perhaps if missing tiddlers inherited the newest or oldest dates of the title that mentions them?

Do you first create an unsorted list of your tiddlers: <$set name=titles filter="blah blah">

Then list using a filter like "[enlist<titles>!has[created]] +[enlist<titles>has[created]sort[created]]"?

1 Like

I tend to use :sort rather than sort in situations where I want to provide a fallback value. In this case, I might try something like this:

:sort:date[get[created]else[99991231000000000]]
:sort:date:reverse[get[created]else[99991231000000000]]
2 Likes

I recall mention at some point of special values high and low values so we could say this;

:sort:date[get[created]else<low-values>]
:sort:date:reverse[get[created]else<high-values>]

However the sort[] and presumably :sort place

  • special characters before numbers (eg date)
  • Alphabetic after numbers

So we can possible do this

\define high-values() !
\define low-values() Z

...
:sort:date[get[created]else<low-values>]
:sort:date:reverse[get[created]else<high-values>]
  • So far not tested

Partial test

\function lister()  1 : 100 ? _ ! C D E A B 20240102033099999 20240102033099997 20250102033099999 ABC +[sort[]join[ ]]

<<lister>>

results in

_ : ! ? 1 100 20240102033099997 20240102033099999 20250102033099999 A ABC B C D E