List from fields

Hi,

I have this to give a list of the contents of the field ‘A’ sorted by field ‘B’

{{{ [all[tiddlers]has[A]get[A]sort[B]] }}}

If field ‘A’ had multiple words (there is a reason), how could I produce the same list but just the first word from each field?

Thanks
Jon

sorted by field ‘B’

…then you should probably use sortby

You use the :map filter prefix. I guess something like this but didn’t test it:

{{{ [all[tiddlers]has[A]get[A]sortby[B]] :map[first[]] }}}

1 Like

Thanks Mat, but no joy.

Produces a list including the multiple values from each field rather than just the first one.

Regards
Jon

{{{ [all[tiddlers]has[A]get[A]sort[B]] :map[split[ ]first[]] }}}
1 Like

Hi Saq,

that’s closer - but in the example below, the output is ‘apple’ rather than

apple
pear
banana

Tiddler1: Field A: apple, orange, lemon
Tiddler 2: Field A: pear
Tiddler 3: Field A: banana

Jon

Given the example tiddlers, the output should be:

apple,
pear
banana

Try it on tiddlywiki.com and report back if that is not the case.

You’re right, it does work on TW and also when I create a new list in my wiki - but strangely not for the pre-existing list. I’ll have to dig around to see what’s going wrong.

Thanks a lot
Jon

Did you check for typos or additional spaces in your field names?

Hi Mario,

I’ve not had a chance to properly look at things but all that appears to be fine.

I’ve had problems with the behaviour of fields in this particular wiki before.

I’ve just tried adding another tiddler with ‘X’ in the field and this doesn’t show in the output list but if I enter ‘X Y Z’ then X does show but as mentioned, the formula works as expected in another wiki.

On a side note, I’ve noticed that the sort doesn’t work when I try it at TW.com - using ! doesn’t reverse it,

Jon

Sort the tiddlers before you get the field value.

I think I tried every combination apart from that one!

Thanks
Jon