Sorting using select widget

HI,

i recently learned that i can put a value in a select widget as such

Filter By 
<$select  tiddler=<<currentTiddler>>
field="statusfilter"…>
<option value="[status[Completed]]">Completed</option>

for which i can then take the value set in the field , put it in a variable , then use the variable in a filter

so <$set name="statusfilter" value={{{[{!!statusfilter}]}}}>

<$list filter=" [subfilter<statusfilter>tidtype[task]]">

and now i can switch between multiple filters

so i tried the same with sorting, only the value i am using to do the sort is the outcome of a tagtree filter

<option>title</option>
<option value="[<currentTiddler>tagstree[]has:field[tidtype]get[Priority]sum[]]">priority</option>

<$list filter=" [subfilter<statusfilter>tidtype[task]]+[sort<statussort>]">

it didnt work , they are not sorted properly , is there something i am doing wrong ?

thanks

The sort operator only takes a field name as its parameter, and sorts the input tiddlers based on their respective values of that field. You may be looking for sortsub, which will sort by the results of a subfilter, stored in a variable.

I’d try something like this:

Filter By 
<$select field="statusfilter">
<option value="[status[Completed]]">Completed</option>
</$select>

Sort By
<$select field="statussort">
<option value="[tagstree[]has:field[tidtype]get[Priority]] +[sum[]]">priority</option>
</$select>

<$list filter="[subfilter{!!statusfilter}tidtype[task]] +[sortsub:number{!!statussort}]">

</$list>

As a side note, you should be able to use <$list filter="[subfilter{!!statusfilter}tidtype[task]]"> and thus eliminate the set widget.

The sort filter operator expects a fieldname as the filter operand, but you are trying to use a “nested” filter syntax.

Try replacing the +[sort<statussort>] with a separate :sort:number[...] filter run prefix, like this:

<$list filter=" [subfilter<statusfilter>tidtype[task]] :sort:integer[subfilter<statussort>]">

Let me know how it goes…

-e

1 Like

It worked , thank you eric :slight_smile:

OK sorry to come again,

i think i have another problem , i use the same select widget to sort by title , or by date i mean, now that i have committed the filter to sort by Integer, i cant use the same select widget any more to feed the filter other non integer values