multiple sorts in andtidwiki

56 views
Skip to first unread message

StephanF

unread,
Jul 2, 2017, 2:12:03 PM7/2/17
to TiddlyWiki
Hi everybody!
I pass this parameter  filter:[tag[jrnl_veh]sort[title]sort[vehicle]]   to a macro to list all tiddlers tagged jrnl_veh sorted by title within vehicle (a field defined in these tiddlers). In Firefox on a Windows 8.1 box it works just as it should. In andtidwiki on a samsung tablet it results in a list properly sorted by title within the first vehicle, but in random (or at least not sorted) title order within the second vehicle. It must be sorting the titles in the first vehicle since the tiddlers were not entered in the desired order (it is a journal style title with a yyyy-mm-dd date).

How can this be? If the browser is just hosting/displaying, how can a sort be affected. The only explanation I can think of is the javascript engine in andtidwiki doesnt work precisely like the one in Firefox. Are there any other examples of this sort of thing? Is there a different way I could do the sort so that it works properly in andtidwiki?

Thanks in advance for any and all help and advice :)
Stephan

Mark S.

unread,
Jul 2, 2017, 5:35:07 PM7/2/17
to TiddlyWiki
The sort[] filter is underpinned by the javascript sort() function, which is not guaranteed to be stable. That is, each time a sort is encountered it can just grab the array however it wants, ignoring the original sort order.

One work-around would be to make a field, e.g. "sortby", that concatenates the vehicle name and the title field. A button could run a <list> with <action-setfield> to set this field for you automatically rather than populating by hand. Then just sort by the sortby field. You could have multiple sortby fields (e.g. sortbyVehicleOwner) for different ways you want to sort.

HTH
Mark

Mark S.

unread,
Jul 2, 2017, 7:13:10 PM7/2/17
to TiddlyWiki
D'oh.

I forgot that you can get the result you want by nesting two list widgets, like:

<$list filter="[has[vehicle]each[vehicle]get[vehicle]sort[]]" variable="vehicle">
<$list filter="[field:vehicle
<vehicle>sort[]]">
<$view field="vehicle"/> - <$view field="title"/>
<br/>
</$list>
</$list>

HTH
Mark

On Sunday, July 2, 2017 at 11:12:03 AM UTC-7, StephanF wrote:
Reply all
Reply to author
Forward
0 new messages