이 문서는 https://tiddlywiki.com/languages/ko-KR/에서 티들리위키의 정적 HTML 표현의 일부입니다

sortsub Operator

2024년 7월 17일 오전 11:57
purposesort the input by the result of evaluating a subfilter for each item
inputa selection of titles
suffixT=the type used for the comparison (string, number, integer, date, version), defaulting to string
parameterS=a subfilter to be evaluated
outputthe input, sorted into ascending order by the result of evaluating subfilter S
! outputthe input, sorted into reverse order by the result of evaluating subfilter S

Learn more about how to use Filters

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 S, 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 value of currentTiddler outside the subfilter is available in the variable ..currentTiddler. Introduced in v5.2.0

The suffix T determines how the items are compared and can be:

  • string (the default)
  • number - invalid numbers are interpreted as zero
  • integer - invalid integers are interpreted as zero
  • date - invalid dates are interpreted as 1st January 1970
  • version - invalid versions are interpreted as "v0.0.0"
  • alphanumeric - treat items as alphanumerics Introduced in v5.2.0

Tip
Note that subfilters S should return the same number of items that they are passed. 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]].

Any missing entries will be treated as zero or the empty string.

Also see: Sort Filter Run Prefix

Examples