On Monday, January 18, 2016 at 12:21:31 AM UTC-8, Richard Evans wrote:
>
> I have been exploring the filter mechanism in TW5. First I am surprised to 
> find it classified as a Concept, rather than as a Widget, but as I have 
> said before the logic of the TiddlyWiki language escapes me.
>

Filters can be used as parameter values for several different types of 
Widgets, including $list, $set, various $action-* widgets, etc.  They can 
also be used in some special cases, such as entering a filter expression 
into $:/DefaultTiddlers to automatically compute which tiddlers are to be 
shown at startup (e.g., put [tag[startup]] in $:/DefaultTiddlers, and then 
just add the "startup" tag to any tiddlers you want displayed).
 

> If I use the following code:-
>
> <ul><$list filter="[tag[Use Case]]" sort="title">
> <li>
> <$link><<currentTiddler>></$link> 
> </li>
> </$list></ul>
>

The documentation for the <$list> widget does not include mention of a 
sort="..." parameter, so I don't think any sorting actually occurred. 
 Rather, I think you are just seeing the "natural" order (based on 
creation) of the tagged tiddlers.  To actually sort the filter output, you 
should use the [sort[]] filter operator, like this:
<$list filter="[tag[Use Case]sort[title]]">
 

> Am I alone in thinking that a filter is different from a sort? Making sort 
> subsiduary to filter seems illogical to me.
>

Filter operators work by modifying the current "input set" in various 
ways... adding, removing or changing the order of the items in the set.  By 
default, the input set starts with all 'real' tiddlers (excluding shadow 
tiddlers).  The [tag[...]] operator then selects only those tiddlers with 
the indicated tag value.  The [sort[...]] operator then alters the order of 
the set of tiddlers.

Sorting a set can be integral to the logic of filtering.  For example, 
suppose I want to list, in alphabetical order, the ten most recent tiddlers 
tagged with "task".  To achieve this, the filter expression would be:
[tag[task]!sort[modified]limit[10]sort[title]]

Note also that the [sort[...]] operator uses a standard character-based 
sort, so numbers are treated as simple strings of characters, rather than 
numeric values.  To sort by *numeric value*, use the [nsort[...]] operator 
instead.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals


-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c9678632-b435-4ce6-b733-56326b3ea6d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to