Thank you so much Eric you have saved me yet again! I really appreciate you 
taking the time to help me out.

On Wednesday, 22 April 2020 23:22:31 UTC+1, Eric Shulman wrote:
>
> On Wednesday, April 22, 2020 at 11:30:41 AM UTC-7, si wrote:
>>
>> Hi everyone.
>> I'm trying to implement a particular type of task list using plain 
>> wikitext. I stole the idea from supermemo 
>> <https://supermemo.guru/wiki/Tasklist>.
>> Each of my tasks is tagged *task*, and has the fields *time *and *value*. 
>> These fields represent the estimated time a task will take and the 
>> perceived value of a task respectively.
>> I'm trying to generate a task list that is sorted by the result of *value 
>> divided by time* for each task.
>> I thought this would be able to do this easily, then tried it and 
>> realised I couldn't. Can anyone help me out here?
>>
>
> I did something similar to create a "tag cloud", where the tags are sorted 
> by the number of tiddlers they are tagging.
> See 
> http://tiddlytools.com/filtergenerators.html#TiddlyTools%2FFilterGenerators%2FTagCloud
>
> For your purposes, the code is actually quite a bit simpler than the 
> TagCloud.  This should do the job:
> \define getitems()
> <$list filter="[tag[task]]">
>    <$vars time={{!!time}} value={{!!value}}>
>    <$text text="[["/>{{{ [<value>divide<time>divide[10000]] }}};<<
> currentTiddler>><$text text="]]"/>
>    </$vars>
> </$list>
> \end
>
> <$wikify name="items"  text=<<getitems>>  >
>    <$list filter="[enlist<items>nsort[]]">
>       {{{ [<currentTiddler>split[;]last[]] }}}<br>
>    </$list>
> </$wikify>
>
> The <<getitems>> macro:
> * gets all tiddlers tagged with "task"
> * calculates the "value/time" number for each and divides it by 10000 to 
> ensure that all numbers are zero-padded for proper sorting (so a value, 
> e.g., "15" is not sorted between "1" and "2")
> * prepends that calculated value in front of each task title, separated by 
> a semi-colon (;) and surrounded by double square brackets to handle titles 
> with spaces
>
> The calling code:
> * Uses $wikify to capture the output of <<getitems>> into a variable, 
> "items"
> * The $list widget then enlists the items and sorts them numerically
> * The output then strips off the calculated number and the semi-colon 
> separator and displays the tiddler titles in the sorted order
>
> Let me know how it goes...
>
> enjoy,
> -e
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/37d4d40b-ce4f-44ad-b2a0-8a4217ebf502%40googlegroups.com.

Reply via email to