1

最好使用作者的姓氏对列表进行排序。

我在其中一个提琴手中有此代码,它列出了所有标记为“作者”的提琴手并按字母顺序排序:

<$list filter='[tag[author]sort[title]]'>

</$list>

例如

Adam Robinson
Andrew Adonis
Benjamin Franklin
Dale Carnegie
Daniel Priestley
George Leonard

我希望列表按姓氏排序,所以它看起来像这样:

Adonis, Andrew 
Carnegie, Dale
Franklin, Benjamin
Leonard, George
Priestley, Daniel
Robinson, Adam 

任何想法如何做到这一点?

4

2 回答 2

0

In recent versions of TiddlyWiki, you can do this with the sortsub operator, which sorts based on the results of applying a filter expression to the inputs. Note that when you use this operator (or any other operator that takes a subfilter), you have to define the subfilter using a macro, or there's no way for TiddlyWiki to tell which square brackets are part of the main filter and which are part of the subfilter.

Here's a minimal working version:

\define myfilt() [split[ ]last[]]

<$list filter="[tag[author]sortsub<myfilt>]">
  ...
</$list>

To get the display to show up as "Lastname, Firstname", as in your example, rather than just showing the title of the tiddler as is:

\define myfilt() [split[ ]last[]]

<$list filter="[tag[author]sortsub<myfilt>]">
  <$set name=formattedName value={{{ [all[current]split[ ]last[]addsuffix[, ]] [all[current]split[ ]butlast[]] +[join[]] }}}>
    <$link to=<<currentTiddler>>><<formattedName>></$link><br>
  </$set>
</$list>

We calculate the new format using a filter in {{{ triple curly braces }}} and assign it to a variable (note the use of butlast[] rather than first[] so that if someone has more than two names, the middle ones go on the end rather than disappearing). Then we create a link whose text is that new formatted version, and whose target is the original tiddler name.

于 2021-04-19T20:56:40.727 回答
0

简单的选项:添加一个按您想要的方式填充的 ByLastName 字段并对其进行排序。

中等选项:将生成字段的概念引入 tiddlywiki。

硬选项:修改排序过滤器以使用您指定的任何数据调用宏,然后根据结果对原始列表进行排序。

于 2017-06-29T16:35:25.763 回答