Hi Mohammad,

Here is the main function in  $:/core/modules/filters/indexes.js :

exports.indexes = function(source,operator,options) {
        var results = [];
        source(function(tiddler,title) {
                var data = options.wiki.getTiddlerDataCached(title);
                if(data) {
                        $tw.utils.pushTop(results,Object.keys(data));
                }
        });
        results.sort();
        return results;
};


It indeed sorts the results !


Regards

FrD

Le mardi 21 août 2018 17:57:27 UTC+2, Mohammad a écrit :
>
> Thank you Mark!
> I edited my question! yes the correct code was
> <$list filter="[[My Alert Class Dictionary]indexes[]addprefix[bg-] 
> -index[bg-warning bg-light]]" variable="alert-type">
> <<alert-type>><br>
> </$list>
>
> No I learned I can remove those indexes (light and warning) before adding 
> the prefix bg-
>
> I use chrome and for me the results by indexes operator is sorted! not 
> good for what i want to do!
>
> Mohammad
>
>
> On Tuesday, August 21, 2018 at 8:15:39 PM UTC+4:30, Mark S. wrote:
>>
>> I'm not sure what bg-warn and bg-light are, since they're not in your 
>> dictionary.
>>
>> You can only do boolean subtract on an entire filter run -- not inside a 
>> run.
>>
>> So this might work for the first part:
>>
>> [[My Alert Class Dictionary]indexes[]addprefix[alert-]]
>>
>> If you just wanted to remove warn and light, then maybe this:
>>
>> [[My Alert Class 
>> Dictionary]indexes[]!prefix[warn]!prefix[light]addprefix[alert-]]
>>
>> Whenever a TW filter has a title list, it compresses it (eliminates 
>> duplicates), so I imagine that it may also incidentally sort the results. I 
>> haven't looked at the code, but if it was me I would just use javascript's 
>> ability to eliminate duplicates, then pull out the unique values. That 
>> might imply that sorting would be dependent on which browser you used, 
>> since different javascript engines might have internal differences.
>>
>> -- Mark
>>
>> On Tuesday, August 21, 2018 at 8:00:16 AM UTC-7, Mohammad wrote:
>>>
>>>
>>>
>>> I have a dictionary tiddler as below (My Alert Class Dictionary)
>>>
>>> primary:x
>>> secondary:x
>>> info:x
>>> success:x
>>> warning:x
>>> danger:x
>>> light:x
>>> dark:x
>>>
>>>
>>>
>>> I used the idea by Mark S to list my classes except warning and light, 
>>> so I used the below snippet, but it doesn't work?
>>>
>>>
>>> <$list filter="[[My Alert Class Dictionary]indexes[]addprefix[alert-] 
>>> -index[bg-warning bg-light]]" variable="alert-type">
>>> <<alert-type>><br>
>>> </$list>
>>>
>>>
>>> Q2.
>>>  Why the above list widget sorts indexes in output while I have not used 
>>> sort[title]?
>>>
>>>
>>> -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 [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/0491d062-2577-45cb-b454-e7e0304f3268%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to