purpose | sort the input by the result of evaluating a subfilter for each item |
---|---|
input | a selection of titles |
suffix | T = the type used for the comparison (string, number, integer, date, version), defaulting to string |
parameter | S = a subfilter to be evaluated |
output | the input, sorted into ascending order by the result of evaluating subfilter S |
! output | the input, sorted into reverse order by the result of evaluating subfilter S |
Each item in the list of input titles is passed to the subfilter in turn. The subfilter transforms the input titles into the form needed for sorting. For example, the subfilter [length[]]
transforms each input title in the number representing its length, and thus sorts the input titles according to their length.
Note that within the subfilter, the "currentTiddler" variable is set to the title of the tiddler being processed. This permits subfilters like [{!!value}divide{!!cost}]
to be used for computation.
The suffix T
determines how the items are compared and can be:
Note that subfilters should return the same number of items that they are passed. Any missing entries will be treated as zero or the empty string. In particular, when retrieving the value of a field with the get Operator it is helpful to guard against a missing field value using the else Operator. For example [get[myfield]else[default-value]...
.