Looking at things store.getTaggedTiddlers() = 
store.reverseLookup("tags"...etc)
Which sorts it's output by the titles titles using sortTiddlers().

So it looks like the actual problem is somewhere in this part of the core:
Which looks like a basic sort function so I just have to figure out how to 
turn it into a natural sort function. 

// Sort a list of tiddlers
TiddlyWiki.prototype.sortTiddlers = function(tiddlers,field)
{
    var asc = +1;
    switch(field.substr(0,1)) {
    case "-":
        asc = -1;
        field = field.substr(1);
        break;
    case "+":
        field = field.substr(1);
        break;
    }
    if(TiddlyWiki.standardFieldAccess[field]) {
        if(field=="title") {
            tiddlers.sort(function(a,b) {return a[field].toLowerCase() < 
b[field].toLowerCase() ? -asc : (a[field].toLowerCase() == 
b[field].toLowerCase() ? 0 : asc);});
        } else {
            tiddlers.sort(function(a,b) {return a[field] < b[field] ? -asc 
: (a[field] == b[field] ? 0 : asc);});
        }
    } else {
        tiddlers.sort(function(a,b) {return a.fields[field] < 
b.fields[field] ? -asc : (a.fields[field] == b.fields[field] ? 0 : +asc);});
    }
    return tiddlers;
};



On Saturday, May 30, 2015 at 7:22:54 AM UTC-7, Arc Acorn wrote:
>
> The more I tinker with this the more I think that this may require a core 
> modification. 
> Since it seems like the core issues is how: store.getTaggedTiddlers();
> gathers it's list of tiddlers. 
>
> On Wednesday, May 27, 2015 at 3:08:07 PM UTC-7, Arc Acorn wrote:
>>
>> This is the plugin I'm using:
>> http://dots.tiddlyspace.com/TreeviewPluginPlugin2
>>
>>
>> As of now trees with leading numbers sort like:
>>
>> 1 10 100 11 12 13 2 3 4 5...
>>
>> I know the reason is how strings are sorted and a naturalsort function 
>> needs to be worked in:
>> eg: 
>>
>> function naturalSort(ar, index){
>>     var L= ar.length, i, who, next, 
>>     isi= typeof index== 'number', 
>>     rx=  /(\.\d+)|(\d+(\.\d+)?)|([^\d.]+)|(\.(\D+|$))/g;
>>     function nSort(aa, bb){
>>         var a= aa[0], b= bb[0], a1, b1, i= 0, n, L= a.length;
>>         while(i<L){
>>             if(!b[i]) return 1;
>>             a1= a[i];
>>             b1= b[i++];
>>             if(a1!== b1){
>>                 n= a1-b1;
>>                 if(!isNaN(n)) return n;
>>                 return a1>b1? 1: -1;
>>             }
>>         }
>>         return b[i]!= undefined? -1: 0;
>>     }
>>     for(i= 0; i<L; i++){
>>         who= ar[i];
>>         next= isi? ar[i][index] || '': who;
>>         ar[i]= [String(next).toLowerCase().match(rx), who];
>>     }
>>     ar.sort(nSort);
>>     for(i= 0; i<L; i++){
>>         ar[i]= ar[i][1];
>>     }
>> }
>>
>>
>>
>> However I can't for the life of me figure out how to incorporate the 
>> natural sort function into the treeview plugin.... 
>> Any help would be greatly appreciated.
>> . 
>>
>

-- 
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 post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c41b16f1-ca86-4a54-8e25-172c388043c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to