1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 02:19:55 +00:00

first attempt at fixing wrong sort order in nsort and nsortcs

not working yet, no idea why
This commit is contained in:
Tobias Beer 2015-01-23 12:06:32 +01:00
parent f4005871b4
commit ad62d9a083

View File

@ -314,7 +314,7 @@ Sort an array of tiddler titles by a specified field
isCaseSensitive: true if the sort should consider upper and lower case letters to be different
*/
exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,isNumeric) {
var self = this;
var x,y,self = this;
titles.sort(function(a,b) {
if(sortField !== "title") {
var tiddlerA = self.getTiddler(a),
@ -330,10 +330,13 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,is
b = "";
}
}
if(isNumeric) {
a = Number(a);
b = Number(b);
return isDescending ? b - a : a - b;
x = Number(a);
y = Number(b);
if(isNumeric && (!isNaN(x) || !isNaN(y))) {
return
isNaN(x) && !isNaN(y) ? (isDescending ? -1 : 1) :
!isNaN(x) && isNaN(y) ? (isDescending ? 1 : -1) :
isDescending ? x - y : y - x;
} else if($tw.utils.isDate(a) && $tw.utils.isDate(b)) {
return isDescending ? b - a : a - b;
} else {