Double sort of filtered list for ToDoNow

205 views
Skip to first unread message

Surya

unread,
Apr 5, 2018, 10:22:42 AM4/5/18
to TiddlyWiki
Hi,

I use the plugin ToDoNow (https://tid.li/tw5/tdn.html) and added a tiddler for showing me the overdue tasks and the tasks for today and the next seven days with:
<$set name="listfilter" value="""[all[]tag[ToDo]][all[]tag[ToDoNow]] +[days:todo-deadline[7]sort[todo-deadline]]""">

<ul class="te-list">
<$list filter=<
<listfilter>> emptyMessage="<li class='todo-empty'><<telang 'Relax-Nothing-to-do'>></li>">
   <
<todonowShowListItem>>
</$list>
</ul>

</$set>


Now I'd like to additionally sort the tasklist by title. It should be sorted at first by todo-deadline and then by title.
I tried it with
<$set name="listfilter" value="""[all[]tag[ToDo]][all[]tag[ToDoNow]] +[days:todo-deadline[7]sort[title]sort[todo-deadline]]""">

<ul class="te-list">
<$list filter=<
<listfilter>> emptyMessage="<li class='todo-empty'><<telang 'Relax-Nothing-to-do'>></li>">
   <
<todonowShowListItem>>
</$list>
</ul>

</$set>

But that doesn't work.


I tried to combine in different ways the original with this
<ul> <$list filter="[tag[Composers]each[surname]get[surname]sort[]]" variable="name"> <$list filter="[tag[Composers]surname<name>sort[middlename]sort[givenname]]"> <li> <$link> <$view field="surname"/>, <$view field="givenname"/> <$view field="middlename"/> </$link> </li> </$list> </$list> </ul>
But they also didn't work.


How can I write it, that the double sort works?

Do you know any help for this?
Thanks :-) Surya

Mark S.

unread,
Apr 5, 2018, 12:42:17 PM4/5/18
to TiddlyWiki
AFAIK, there currently is no way to do a multiple sort this way. The last sort you invoke will win. In theory you should be able to use two nested lists, with the outer list issuing one tiddler per day and the inner list finding all tiddlers on the sameday (using the sameday operator). Unfortunately, it appears that the sameday operator might be buggy, or perhaps the ToDo application doesn't format dates correctly. I'll post my code here -- maybe someone can figure out what's wrong.

<$set name="listfilter" value="""[all[]tag[ToDo]][all[]tag[ToDoNow]] +[has[todo-deadline]days:todo-deadline[7]eachday[todo-deadline]sort[todo-deadline]]""">
<$set name="listfilter2" value="""[tag[ToDo]has[todo-deadline]sameday{!!todo-deadline}] [tag[ToDoNow]has[todo-deadline]sameday{!!todo-deadline}] +[sort[]]""">


<ul class="te-list">
<$list filter=<
<listfilter>> emptyMessage="<li class='todo-empty'><<telang 'Relax-Nothing-to-do'>></li>
">
<$list filter=<
<listfilter2>> >

   <
<todonowShowListItem>>

</$list>
</$list>
</ul>

</$set></$set>

The other approach would be to use a button that creates a new field (maybe due-title) that concatenates the due date and the title. Then you could sort by due-title. The downside is that you have to update the fields before doing your listing.

Good luck!
Mark

Surya

unread,
Apr 5, 2018, 1:54:08 PM4/5/18
to TiddlyWiki
Hi Mark,

yes, like you mentioned, your code doesn't work (I tried it nevertheless, just to see what it does). It sorts only by title. Also the "look" is different.

Your second suggestion with the button that creates a new field "due-title":
How could I update the fields of all tasks, before calling the list-tiddler?

Surya

Mark S.

unread,
Apr 5, 2018, 2:14:27 PM4/5/18
to TiddlyWiki
You would just put a button at the top that says "Refresh Data."  An inconvenience, but not too difficult.

-- Mark

Thomas Elmiger

unread,
Apr 5, 2018, 2:52:39 PM4/5/18
to TiddlyWiki
Hi Surya

In my test this works:

<$set name="listfilter" value="""[all[]tag[ToDo]][all[]tag[ToDoNow]] +[days:todo-deadline[17]] +[sort[title]sort[todo-deadline]]""">


<ul class="te-list">
<$list filter=<<listfilter>> emptyMessage="<li class='todo-empty'><<telang 'Relax-Nothing-to-do'>></li>">
   <<todonowShowListItem>>
</$list>
</ul>

</$set>

I think you can even remove sort[title] as sorting by title might be the default. I get the same result without it in any case.

In my experience it is the best way to put the sorting steps in a separate "run" of the type AND according to

And hey, it took me a while to grasp that concept ;–)

Good luck!
Thomas

Surya

unread,
Apr 5, 2018, 3:46:52 PM4/5/18
to TiddlyWiki
Hello Thomas,

I have been so happy reading your post :-) It would have been so easy...
But... unfortunately it doesn't work on my wiki. The list is sorted by todo-deadline, but then not by title.

Maybe it is because of my titles??
Every task begins like this:
  • K01: Text of task
  • K02: Text of task
  • K03: Text of task
  • ....
  • K10: Text of task
  • K11: Text of task
  • K12: Text of task
  • and so on
The beginning is the location, where I have to do it. Maybe, the problem are the numbers?
Surya

Thomas Elmiger

unread,
Apr 5, 2018, 4:09:50 PM4/5/18
to TiddlyWiki
Hi again

O.k. we need the title:

<$set name="listfilter" value="""[all[]tag[ToDo]][all[]tag[ToDoNow]] +[days:todo-deadline[17]] +[sort[title]sort[todo-deadline]]""">

My result:

If this is not what you want (sort by date, then by title = location), then maybe you want a list by location, then by date?
In this case you would have to switch the sorts: +[sort[todo-deadline]sort[title]]

The sorts are kind of inverted, like in Excel. The last sort wins, but if the criterion is the same in the last sort, e.g. "12.04.2018", then the items with that identical attribute are still in the order of the previous sort.

Hope that helps.
Cheers, Thomas

Surya

unread,
Apr 5, 2018, 4:49:39 PM4/5/18
to TiddlyWiki
Hi Thomas,

It works :-)
But only in my browser. I tried it before only on TiddlyDesktop.
There on TiddlyDesktop it didn't work (that doesn't matter- I decided now that I won't use TiddlyDesktop anymore- toooo slow when I work with several programs).
But also not on AndTidwiki on my Android. And there I'll use and need the tasklist most...

Hm, and now?
Should I have to do it like Mark said? No other possibility?
Or won't Marks suggestion with the additional field "due-title" work on AndTidwiki too?
Maybe you don't know that and I just have to try... :-(
Surya

Mark S.

unread,
Apr 5, 2018, 6:11:01 PM4/5/18
to TiddlyWiki
What's happening internally is that an array is being sorted first one way and then another way in Javascript. Whether the ordering from the first sort is retained depends on how the particular browser implements sorting. That's why it doesn't work everywhere. I feel kind of relieved -- I knew there was some reason I went through all those coding gyrations!

I'm rethinking my suggestion. You can't just append the deadline date and the title because the deadline is in UTC. Well, maybe *you* can. That will probably work most of the time for you (you're fairly close to the international timeline, right?) But it might not quite work right if you stay up late or travel abroad.

To work all the time, your button will need to:

1. List through ToDo and ToDoNow tiddlers, finding a set that each has a distinct day (using the each day operator).
2. Then use those to find the current day (wikifying <$view format=date ...>, let's call it curDay) . Then
3. Then inside an inner loop look for all tiddlers with sameday
4. Then fill in the sortby field with curDay & title.

Steps 1-3 are very close to what I attempted the first time. So it's just the last step that's novel.

Good luck!
-- Mark

Surya

unread,
Apr 8, 2018, 4:15:25 PM4/8/18
to TiddlyWiki
Hello Mark,


That will probably work most of the time for you (you're fairly close to the international timeline, right?) But it might not quite work right if you stay up late or travel abroad.

I live in Germany and need this task list only here in Germany.
I don't need the time, only the date.
It even doesn't matter, if a task is 1 day too late or 1 day too early (maybe this could be the case sometimes, if for example UTC says it is now the 9. April 9:00 am, but for me in Germany it is 8. April 23:45 pm).

My hope: Because the described things do not matter to me, I could build a solution, which is easier?
Because it seems to me writing this could be really difficult for me (means a lot of questions like "how to write this now and how that..." and so on).

Surya

Mark S.

unread,
Apr 8, 2018, 9:16:58 PM4/8/18
to TiddlyWiki
Hi Surya,

Good news! I think I got my original approach to work:

<$set name="listfilter" value="""[tag[ToDo]][tag[ToDoNow]] +[has[todo-deadline]days:todo-deadline[7]eachday[todo-deadline]sort[todo-deadline]]""">
<$set name="listfilter2" value="""[tag[ToDo]has[todo-deadline]sameday:todo-deadline{!!todo-deadline}] [tag[ToDoNow]has[todo-deadline]sameday:todo-deadline{!!todo-deadline}] +[sort[]]""">

<ul class="te-list">
<$list filter=<
<listfilter>> emptyMessage="<li class='todo-empty'><<telang 'Relax-Nothing-to-do'>></li>

">
<$view field="todo-deadline" format="date" template="YYYY-0MM-0DD"/>
<$list filter=<
<listfilter2>> >

   <
<todonowShowListItem>>

</$list>
</$list>
</ul>

</$set></$set>

You'll probably want to make it look better.

As it turned out, the documentation for "sameday" is wrong. It says to use a date like yyyymmdd but you actually appear to need the full nine digit date-stamp. OR, maybe you can get away with yyyymmdd IF you're living in Greenwich.

HTH!

-- Mark

Surya

unread,
Apr 9, 2018, 4:41:30 PM4/9/18
to TiddlyWiki
Hi Mark,

that's it! It works on my Android with AndTidWiki :-))

Thanks a ton!!

Surya
Reply all
Reply to author
Forward
0 new messages