(TW5) Ordering lists by date

1,341 views
Skip to first unread message

michaelha...@gmail.com

unread,
May 17, 2016, 8:55:08 PM5/17/16
to TiddlyWiki
Having long used TiddlyWiki 5 as a journal, I have lots of tiddlers titled in a dd/mm/yyyy format, such as 29/02/2016.

I am trying to make a list of books I have read, organized by date finished. Here is the code I am using:

<$list filter="[!has[draft.of]tag[reading]sort[finished]]">
<br/>
//<$link to={{!!title}}><$view field="title"/></$link>// by <$view field="author"/> | <$link to={{!!began}}><$view field="began"/></$link> - <$link to={{!!finished}}><$view field="finished"/></$link>

</$list>

The title of the book is the title of the tiddler, and my fields are author, began, and finished, which I expect are fairly self explanatory. This code turns my began and finished dates into links that lead to the relevant journal entries. Unfortunately, the list is being organized by day, not year, then month, then day, as seen here:

Pure by Andrew Miller | 30/04/2016 - 08/05/2016
The Moonstone by Wilkie Collins | 18/02/2016 - 29/02/2016
The Beautiful Things That Heaven Bears by Dinaw Mengestu | 27/04/2016 - 30/04/2016

Does anyone have any suggestions as to how I may adjust the list to display the books in proper chronological order? Thank you.

PMario

unread,
May 18, 2016, 4:31:42 AM5/18/16
to TiddlyWiki
Hi Michael,

TW doesnt know that your field should be interpreted as a date, So the sort order is alphabetical.

You can use YYYY/MM/DD  as a format. It will still be sorted alphabetically but this time it works, since this format naturally sorts.

have fun!
mario

michaelha...@gmail.com

unread,
May 18, 2016, 7:54:36 AM5/18/16
to TiddlyWiki

Mario,

Thank you for your suggestion. While that is certainly something I can try, my difficulty stems from the fact that my journal tiddlers are titled in a dd/mm/yyyy format. If I was to list the dates in the "began" and "finished" fields as YYYY/MM/DD, then they would no longer function as links. Is there any way around this?

Thank you,

Michael

PMario

unread,
May 18, 2016, 8:31:37 AM5/18/16
to TiddlyWiki
On Wednesday, May 18, 2016 at 1:54:36 PM UTC+2, michaelha...@gmail.com wrote:
Thank you for your suggestion. While that is certainly something I can try, my difficulty stems from the fact that my journal tiddlers are titled in a dd/mm/yyyy format.

I see!
 
If I was to list the dates in the "began" and "finished" fields as YYYY/MM/DD, then they would no longer function as links. Is there any way around this?

You can open the control panel and set the "Title of new journal tiddlers" setting to: YYYY/0MM/0DD So they will be created in the same way.
see: http://tiddlywiki.com/#%24%3A%2FControlPanel

I know that's not really a good solution if you already have a lot of journal tiddlers. ... It may be a lot of work but probably less, than changing TWs behaviour.

-m

michaelha...@gmail.com

unread,
May 18, 2016, 8:44:55 AM5/18/16
to TiddlyWiki
Mario,

Thank you for your help. Unfortunately I have about three and a half years worth of journal tiddlers already, and renaming all of those for the sake of one list really does not seem efficient. I expect I will just have to find some other way of organizing the information.

Thanks,

Michael

PMario

unread,
May 18, 2016, 9:06:32 AM5/18/16
to TiddlyWiki
On Wednesday, May 18, 2016 at 2:44:55 PM UTC+2, michaelha...@gmail.com wrote:
Thank you for your help. Unfortunately I have about three and a half years worth of journal tiddlers already, and renaming all of those for the sake of one list really does not seem efficient. I expect I will just have to find some other way of organizing the information.

Yea, that hurts. ... So we have to think about a better solution :/

may be improving the sort[] filter parameter. It may be useful in general.

What do the "filter gurus" think??
-m

PMario

unread,
May 18, 2016, 9:14:28 AM5/18/16
to TiddlyWiki
may be an extension similar to sortby: http://tiddlywiki.com/#sortby%20Operator:[[sortby%20Operator]]%20[[sortby%20Operator%20%28Examples%29]]

eg: sortbydate[DD/MM/YYYY] or so




prog...@assays.tv

unread,
May 18, 2016, 9:23:35 AM5/18/16
to TiddlyWiki
michaelha... & PMario

i am not a programmer BUT isn't the fact that these JOURNAL entries were CREATED at certain exact times recorded at that moment into a (hidden) field? Could they not be sorted by that?

josiah

The Bo

unread,
May 18, 2016, 9:42:05 AM5/18/16
to TiddlyWiki
If your "finished"-field is identical to your last modification you could try sort[modified].

Mark S.

unread,
May 18, 2016, 10:30:14 AM5/18/16
to TiddlyWiki
... or sort[created] for the creation date.

You can also make the created date visible by changing the value of $:/config/EditTemplateFields/Visibility/created to "show". That would allow you to fix those journal entries that had been created out of order. You have to be careful not to delete any of the digits. But if you just change the first 8, you should be all right. I believe the first 8 digits are in yyyymmdd order.

Mark

michaelha...@gmail.com

unread,
May 18, 2016, 10:45:25 AM5/18/16
to TiddlyWiki
Thank you, everyone, for your input, but--and I may be mistaken--I think this may have gotten off topic somewhere. I am not trying to change my journal tiddlers (if I can help it). I am trying to make a list of books I have read, each as its own tiddler, and organized by the date I finished the book.

Again, here is the code I am using:


<$list filter="[!has[draft.of]tag[reading]sort[finished]]">
<br/>
//<$link to={{!!title}}><$view field="title"/></$link>// by <$view field="author"/> | <$link to={{!!began}}><$view field="began"/></$link> - <$link to={{!!finished}}><$view field="finished"/></$link>

</$list>

At the moment, I get a list like this:


Pure by Andrew Miller | 30/04/2016 - 08/05/2016
The Moonstone by Wilkie Collins | 18/02/2016 - 29/02/2016
The Beautiful Things That Heaven Bears by Dinaw Mengestu | 27/04/2016 - 30/04/2016

I am trying to find a way to get this list in chronological order, rather then numerical. However, I am trying to keep the dd/mm/yyyy format, so I can use the dates as links to my journal entries.

Does this make sense?

Mark S.

unread,
May 18, 2016, 12:48:55 PM5/18/16
to TiddlyWiki
If your "finished" tiddlers were created on the same date they were finished, then sorting by "created" instead of "finished" should accomplish what you want. The "finished" field then becomes a link/descriptor field.

For those tiddlers that you did not create on the actual finish date, you can go and tweak the "created" date so that they are in sync. The created date can be revealed by changing the contents of the shadow tiddler

$:/config/EditTemplateFields/Visibility/created

Please specify if there is something wrong with this approach, since it seems like it should match up closely to what you want. Of course, if you made all those tiddlers on days different from their date stamp, then that won't work.


Good Luck,
Mark

michaelha...@gmail.com

unread,
May 18, 2016, 1:13:26 PM5/18/16
to TiddlyWiki
Mark,

Thank you, that method looks like it should work. Having tried it though, I find myself running into a bit of an issue. I have updated my code to look like this:

<$list filter="[!has[draft.of]tag[reading]sort[!created]]">
<br/>
//<$link to={{!!title}}><$view field="title"/></$link>// <$view field="author"/> | <$link to={{!!began}}><$view field="began"/></$link> - <$link to={{!!finished}}><$view field="finished"/></$link>

</$list>

The !created is so that my most recently read books are on the top. However, while using sort[created] puts the tiddlers in sequential order:

The Once and Future King by T. H. White | 10/06/2015 - 29/09/2015
The Moonstone by Wilkie Collins | 18/02/2016 - 29/02/2016
Madame Bovary by Gustave Flaubert | 29/02/2016 - 27/03/2016
Tess of the d'Urbervilles by Thomas Hardy | 28/03/2016 - 25/04/2016
The Beautiful Things That Heaven Bears by Dinaw Mengestu | 27/04/2016 - 30/04/2016
Pure by Andrew Miller | 30/04/2016 - 08/05/2016


Using sort[!created] seems to mix them up for some reason:


Pure by Andrew Miller | 30/04/2016 - 08/05/2016
The Beautiful Things That Heaven Bears by Dinaw Mengestu | 27/04/2016 - 30/04/2016
The Moonstone by Wilkie Collins | 18/02/2016 - 29/02/2016
Tess of the d'Urbervilles by Thomas Hardy | 28/03/2016 - 25/04/2016
The Once and Future King by T. H. White | 10/06/2015 - 29/09/2015
Madame Bovary by Gustave Flaubert | 29/02/2016 - 27/03/2016

Any ideas what is going on here?

Thank you.

Mark S.

unread,
May 18, 2016, 1:25:18 PM5/18/16
to TiddlyWiki
The syntax is  !sort[created]

Good luck!
Mark

michaelha...@gmail.com

unread,
May 18, 2016, 1:37:29 PM5/18/16
to TiddlyWiki
That has done it! Thank you, Mark, and everyone who was kind enough to help me find a solution.

Mark S.

unread,
May 18, 2016, 2:00:58 PM5/18/16
to TiddlyWiki
For anyone interested in living dangerously, here is my first attempt at writing a filter. In the filter syntax, it takes the form

sortddmmyyyy[mydatefield]



I have barely tested it, and have no idea what happens if you throw incorrectly formatted stuff at it. It wants dates like "dd/mm/yyyy". No other separator than /, all 3 fields.

Be absolutely certain to back up your TW if you try this.

Mark
Project_sort_ddmmyyyy-v0.json

PMario

unread,
May 18, 2016, 3:02:02 PM5/18/16
to TiddlyWiki
On Wednesday, May 18, 2016 at 8:00:58 PM UTC+2, Mark S. wrote:
sortddmmyyyy[mydatefield]


I was thinking about a syntax similar to this

sortbydate:fieldname[format]  eg: sortbydate:finished[DD/MM/YYY]  which would make it possible to use any http://tiddlywiki.com/#DateFormat

-m

michaelha...@gmail.com

unread,
May 18, 2016, 10:54:27 PM5/18/16
to TiddlyWiki
Mario,

If I were to try sortbydate:finished[DD/MM/YYYY], how would you suggest I integrate it into the list I have at the moment?

If this is the basic form:


<$list filter="[!has[draft.of]tag[reading]sort[finished]]">
<br/>
//<$link to={{!!title}}><$view field="title"/></$link>// <$view field="author"/> | <$link to={{!!began}}><$view field="began"/></$link> - <$link to={{!!finished}}><$view field="finished"/></$link>

</$list>

Where would sortbydate:finished[DD/MM/YYYY] go in the code? At the least:

<$list filter="[!has[draft.of]tag[reading]sortbydate:finished[DD/MM/YYYY]]">

Does not seem to work.

Mark S.

unread,
May 18, 2016, 11:50:49 PM5/18/16
to TiddlyWiki
The filter Mario is suggesting doesn't exist -- that's why it doesn't work.

I guess I wonder how often anyone needs this particular functionality?

Mark

michaelha...@gmail.com

unread,
May 19, 2016, 9:54:28 AM5/19/16
to TiddlyWiki
Mark,

Thank you for clearing that up, and for your patience with me. I can only assume I am one of the awkward people who uses an awkward date format.

PMario

unread,
May 19, 2016, 11:05:36 AM5/19/16
to TiddlyWiki
On Thursday, May 19, 2016 at 3:54:28 PM UTC+2, michaelha...@gmail.com wrote:
Thank you for clearing that up, and for your patience with me. I can only assume I am one of the awkward people who uses an awkward date format.

No, You and your date format are perfectly fine ;). ... It's just a usecase, where we don't have an "out of the box" solution yet.
-m

Denny

unread,
Jul 14, 2019, 1:45:48 AM7/14/19
to TiddlyWiki
Use this:
<<list-links "[tag[Journal]sort[created]order[reverse]]">>
Reply all
Reply to author
Forward
0 new messages