Multiple sort levels in forEachTiddler

67 views
Skip to first unread message

Mark

unread,
Jun 20, 2009, 7:38:08 AM6/20/09
to TiddlyWiki
I'm using the forEachTiddler plugin to manage a library index. The
library has different document types e.g. books, magazines, DVD's,
journals etc and I'm trying to create a list of library items
(tiddlers) sorted by docType then by author then by title. Sorting by
one field works just fine, but how would one do the multiple levels of
sorting

<<forEachTiddler
where
'tiddler.tags.contains("libEntry")'
sortBy 'tiddler.data("docType")'
write
.......etc

Thanks
Mark

wolfgang

unread,
Jun 20, 2009, 9:20:59 AM6/20/09
to TiddlyWiki
Hi Mark,

The easiest is to use:

http://tw.lewcid.org/#TableSortingPlugin

and adding the following to a table fET write statement:

begin '"|sortable|k\n|...

Regards..

Mark

unread,
Jun 20, 2009, 1:18:04 PM6/20/09
to TiddlyWiki
Thanks Wolfgang. I gave that a go and it certainly does the job, but
has the interesting side effect of taking almost 9 times longer. There
are currently 450 odd items in the library list which takes 1.5
seconds to render in a simple fET write statement, but takes 13
seconds to render as a table. And that was without making the table
sortable. That was in FF3 too - I wouldn't like to try that in IE!

Cheers
Mark

Mark S.

unread,
Jun 20, 2009, 2:13:31 PM6/20/09
to TiddlyWiki
Don't use FET a lot, but looking at the docs, it looks like you might
be able to do something like this with your sort clause:

sortBy 'tiddler.data("docType") + tiddler.data("author") +
tiddler.data("title") '

except of course using whatever actual names you've given to your
author and title fields.

== Mark (an increasingly common name)

wolfgang

unread,
Jun 20, 2009, 2:25:28 PM6/20/09
to TiddlyWiki
> There
> are currently 450 odd items in the library list which takes 1.5
> seconds to render in a simple fET write statement, but takes 13
> seconds to render as a table. And that was without making the table
> sortable. That was in FF3 too - I wouldn't like to try that in IE!
>

For so many items you could use the pagewise script, since you anyway
have to scoll down the list.
For example, I have a fEt in a pretty huge TW of 3.5 MB and almost
1500 item, put it still takes much less to render it this way:
http://change.tiddlyspot.com/#AllTiddlersPageWise

However, with a slow Internet connection, better to download this TW
first, before you view this tiddler:
http://change.tiddlyspot.com/download


Other than that, and the TableSortingPlugin, you can allways place the
differently sorted lists into tabs, like this:


tiddler title: 'Example'
______________________

<<tabs fEt
"By Type" "sort by type" Example##docType
"By Author" "sort by Author" Example##author
>>>/%
!docType
<<forEachTiddler
where
'tiddler.tags.contains("libEntry")'
sortBy 'tiddler.data("docType")'
write
.......etc
!author
<<forEachTiddler
where
'tiddler.tags.contains("libEntry")'
sortBy 'tiddler.data("autor")'
write
.......etc
!end
%/
__________________________

Regards..

Mark

unread,
Jun 20, 2009, 4:08:11 PM6/20/09
to TiddlyWiki
Thanks Mark S that's exactly the syntax I was looking for. It works
just peachy fine.

Cheers
Mark

Mark

unread,
Jun 20, 2009, 4:09:15 PM6/20/09
to TiddlyWiki
That's an intriguing alternative to manage a large list. I'll explore
that one too.

Thanks for the input.
Mark
Reply all
Reply to author
Forward
0 new messages