mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-24 22:33:16 +00:00
first attempt at fixing wrong sort order in nsort and nsortcs
not working yet, no idea why
This commit is contained in:
parent
f4005871b4
commit
ad62d9a083
|
@ -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
|
isCaseSensitive: true if the sort should consider upper and lower case letters to be different
|
||||||
*/
|
*/
|
||||||
exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,isNumeric) {
|
exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,isNumeric) {
|
||||||
var self = this;
|
var x,y,self = this;
|
||||||
titles.sort(function(a,b) {
|
titles.sort(function(a,b) {
|
||||||
if(sortField !== "title") {
|
if(sortField !== "title") {
|
||||||
var tiddlerA = self.getTiddler(a),
|
var tiddlerA = self.getTiddler(a),
|
||||||
|
@ -330,10 +330,13 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,is
|
||||||
b = "";
|
b = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isNumeric) {
|
x = Number(a);
|
||||||
a = Number(a);
|
y = Number(b);
|
||||||
b = Number(b);
|
if(isNumeric && (!isNaN(x) || !isNaN(y))) {
|
||||||
return isDescending ? b - a : a - b;
|
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)) {
|
} else if($tw.utils.isDate(a) && $tw.utils.isDate(b)) {
|
||||||
return isDescending ? b - a : a - b;
|
return isDescending ? b - a : a - b;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user