This is “pre me understanding regular expressions”, and “before I go about refactoring” code.
Usually, whatever we are sorting, we want to sort in either ascending or descending order.
This is about sorting in random order. Useful for gaming, or random quote/tiddler of the day, or whatever else that gives some unpredictability.
The attachment further below has two tiddlers: a javascript macro tiddler for the random macro, and the “Randomize Order of Items” tiddler to see the random sorting in action (push the button for new sort). Download that attachment and drag into TiddlyWiki.com for study/playing.
In case this tempts you a little, the filter formatted for easier reading:
\define thisSort() [split[::]last[]]
{{{
[[1]addsuffix[::]addsuffix<random 999>]
[[2]addsuffix[::]addsuffix<random 999>]
[[3]addsuffix[::]addsuffix<random 999>]
[[4]addsuffix[::]addsuffix<random 999>]
[[5]addsuffix[::]addsuffix<random 999>]
[[6]addsuffix[::]addsuffix<random 999>]
+[sortsub]
+[splitbefore[::]]
+[search-replace[::],[]]
+[join[, ]] }}}
Cheers !
RandomOrderOfItems.json (1.42 KB)