Many thanks FrD. I am not good at JavaScript!
So, I understood the core indexes.js returned the result sorted! I don't
now what is the philosophy behind but it has been restricted this way!
we have the sort[title] and if one needs the result sorted it can be used.
*Mohammad*
On Tuesday, August 21, 2018 at 8:50:13 PM UTC+4:30, FrD wrote:
>
> 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/57a8210d-9a5a-4595-beb5-be6ad265b33a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.