I also want to work with indes and values. But I did not know how to do it combining filters like you. Then i created a new filter cloning * $:/core/modules/filters/indexes.js *and I modified it for obtain values, the important changes are in bold. /*\ values.js type: application/javascript module-type: filteroperator
Filter operator for returning the values of a data tiddler \*/ (function(){ "use strict"; /* Export our filter function */ exports.*values* = function(source,operator,options) { var results = []; source(function(tiddler,title) { var data = options.wiki.getTiddlerDataCached(title); if(data) { $tw.utils.pushTop(results,Object.*values*(data)); } }); return results; }; })(); Now you can use it. [<dataTiddler>values[]] instead the *populate* macro which is filtering the output of other filter. El jueves, 18 de febrero de 2021 a las 20:30:23 UTC+1, Mohammad escribió: > when using nsort on new values (e.g. value::index note :: is a character > used to create new entries) it fails. > One solution is as below, but for large number index - value (e.g 200 or > more) the solution is very slow > > This solution contains > > 1. a populate macro to list all values > 2. a wikify and list widget let sort values > 3. a lookup macro to find index(s) for a value > > \define dataTiddler() myData > \define myfilter() [<dataTiddler>indexes[]] > > \define populate() > <$list filter="[subfilter<myfilter>]"> > <$text text={{{[<dataTiddler>getindex<currentTiddler>]}}}/> > </$list> > \end > > \define lookup-index(val) > <$list filter="[subfilter<myfilter>]" variable=idx> > <$list filter="[<dataTiddler>getindex<idx>] +[match[$val$]]"> > <tr> > <td><$link to=<<idx>> /></td><td> $val$ </td> > </tr> > </$list> > </$list> > \end > > > <table> > <$wikify name=u text=<<populate>> > > <$list filter="[enlist<u>nsort[]]"> > <$macrocall $name=lookup-index val=<<currentTiddler>> /> > </$list> > </$wikify> > </table> > > > The above can be tested in https://tiddlywiki.com/ if one creates a data > tiddler with the myData title containing the data of the previous post. > > Question: as stated above this solution is very slow for large numbers of > data (index-value pairs). What alternative solution do you propose? > > Best wishes > Mohammad > > > On Thu, Feb 18, 2021 at 10:07 PM Mohammad Rahmani <mohammad...@gmail.com> > wrote: > >> This is an old question and there are several solution for that, but not >> for the case I explain here >> >> Assume you have a dataTiddler or JSON tiddler with data like below >> >> nella: -1 >> rita: 1 >> villa: 0 >> lola: -7 >> sina: 3 >> cobra: 2 >> fifa: -2 >> zila: 3 >> afra: 1 >> >> >> I want to list data in this dictionary table sorted by value, so I should >> have >> >> lola: -7 >> fifa: -2 >> nella: -1 >> villa: 0 >> afra: 1 >> rita: 1 >> cobra: 2 >> sina: 3 >> zila: 3 >> >> Note, there are duplicated values. The solution is that new entries >> created from appending value to index like value::index do not work here! >> As you need to use nsort >> >> >> >> Best wishes >> Mohammad >> > -- 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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/65d562c5-88e4-49b1-aa5f-e399ca397a81n%40googlegroups.com.