Hi S.S.,
 Many thanks for detailed explanation! I got why you have used *each *
operator!
This is actually a doubly sorted list! 
Wonderful!

Added to TW-Scripts

--Mohammad

On Monday, April 1, 2019 at 10:31:39 AM UTC+4:30, S. S. wrote:
>
>
> Mohammad,
>
> Well, Michaelha hasn't confirmed that it works yet!
>
> What I did was to test a similar scenario in my own TiddlyWiki.
>
> I have a bunch of books tagged *book*, that have an *author* field, and a 
> (publication) *year* field.
> Some authors have multiple books.
>
> So I tried to list my books so that it sorted first by the Author name (
> *author* field), then subsorted the books of an author by the date of 
> publication (*date* field).
>
> The below did it quite nicely!
>
> <table>
> <$list filter="[tag[book]each[author]get[author]sort[]]">
> <$list filter="[tag[book]field:author<currentTiddler>sort[date]]">
> <tr>
>   <td>
>     //<$link to={{!!title}}><$view field="title"/></$link>//
>   </td>
>   <td>
>     <$view field='author'/>
>   </td>
>   <td>
>     <$view field='date'/>
>   </td>
> </tr>
> </$list>
> </$list>
> </table>
>
> \define Explanation()
>
> The 1st *$list* filter:
>
>    -  Gets a list of all my books (tagged *book*)
>    -  Looks at the *author* field and gets a list of authors using the 
>    *get* operator
>       - Since the *get* operator is one of the few operators that allow 
>       duplicates, it is possible to have the same author listed multiple 
> times in 
>       the list created 
>       - So I first use the *each* operator to ensure unique items 
>    (authors).
>    - Then this list of all authors is sorted by the author's name
>       -  As we know, *sort[] *sorts by *<<currentTiddler>>* which at this 
>       point is the author's name in the *author* field
>    
> The 2nd *$list* filter will now run for each author in the list created 
> by the 1st *$list*
>    
>    - For the first item (*<<currentTiddler>>* - which is the first 
>    author's name)
>    - It first gets a list of all the books (tagged *book*)
>       - Then looks at the *author* field - selects the ones that match 
>       this first author (*<<currentTiddler>>*)
>       - Then sorts those ( *sort[date]* ) by the publication date (*date* 
>       field)
>    - Then it does that for the 2nd author in the list provided by the 1st 
>    *$list* filter 
>    - . . . and so on for all the authors one by one as provided by the 
>    1st *$list* filter.
>
> \end Explanation
>
> I now have a nicely tabled list!
> I'm glad Michaelha asked the question, as I like the way all my books are 
> listed now.
>
> Cheers
>
> On Monday, April 1, 2019 at 11:59:36 AM UTC+7, Mohammad wrote:
>>
>> S.S,
>>  What does each operator do here?
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/d6705a21-a70e-4ca6-9acd-5f69e09fd7c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to