1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-28 16:23:15 +00:00

Refine fix to retain stylesheet ordering

The order of tiddlers in the HTML file uses localeCompare(), and that determines the insertion order. So if we want to be compatible with older versions we have to use localeCompare() to order tiddlers, not a plain sort()
This commit is contained in:
jeremy@jermolene.com 2022-01-08 16:18:04 +00:00
parent ca9f320886
commit 762de81444

View File

@ -75,10 +75,10 @@ $tw.utils.insertSortedArray = function(array,value) {
var low = 0, high = array.length - 1, mid, cmp;
while(low <= high) {
mid = (low + high) >> 1;
cmp = array[mid];
if(value > cmp) {
cmp = value.localeCompare(array[mid]);
if(cmp > 0) {
low = mid + 1;
} else if(value < cmp) {
} else if(cmp < 0) {
high = mid - 1;
} else {
return array;
@ -1101,7 +1101,7 @@ $tw.Wiki = function(options) {
tiddlerTitles = null, // Array of tiddler titles
getTiddlerTitles = function() {
if(!tiddlerTitles) {
tiddlerTitles = Object.keys(tiddlers).sort();
tiddlerTitles = Object.keys(tiddlers).sort(function(a,b) {return a.localeCompare(b);});
}
return tiddlerTitles;
},