How can I add "fuzz" to a task list ordered by priority?

Hi again.

I have a task list sorted by priority. Each task has a priority 1-100. Something like this:

<$list filter="[tag[task]!nsort[priority]]">
{{!!title}} (priority: {{!!priority}})
<br>
</$list>

I’m trying to add some “fuzz” to the sort order to avoid to avoid tasks with the same priority value always clustering together. In other words I want to sort tasks by their priority +/- some random integer between 0 and 5 (or something like that). Using the shuffle operator plugin I’ve ended up with this:

\procedure order() [get[priority]add<fuzz>]

\function fuzz() [range[-5],[5]shuffle[]first[]]

<$list filter="[tag[task]!sortsub:number<order>]">
{{!!title}} (priority: {{!!priority}})
<br>
</$list>

Works great, except that <<fuzz>> refreshes on every button click, so the list is constantly reshuffling. What I want is to apply the fuzz only once when the tiddler containing the list is first opened.

I’m pretty stuck as to how I could approach this. Can anyone help? :slight_smile:

Do you perhaps need to “save” the <<fuzz>>ed list somewhere so it’s not just refreshing each time?

Thank you @hoopyfrood! I managed to get it working by generating a dictionary tiddler on startup that stores every non-system tiddler title as a key, and assigns a fuzz value to it. Then I can use these these values within my sort filter.

Use action-setfield to persist the fizz to
a tiddler