1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 13:29:56 +00:00

Fixed problem with sorting by missing fields

This commit is contained in:
Jeremy Ruston 2012-10-16 21:41:12 +01:00
parent 456b8f9ba8
commit 343a2c2340

View File

@ -216,8 +216,8 @@ exports.getTiddlers = function(sortField,excludeTag) {
} }
} }
tiddlers.sort(function(a,b) { tiddlers.sort(function(a,b) {
var aa = a.fields[sortField].toLowerCase() || 0, var aa = a.fields[sortField].toLowerCase() || "",
bb = b.fields[sortField].toLowerCase() || 0; bb = b.fields[sortField].toLowerCase() || "";
if(aa < bb) { if(aa < bb) {
return -1; return -1;
} else { } else {
@ -247,8 +247,8 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive) {
var self = this; var self = this;
titles.sort(function(a,b) { titles.sort(function(a,b) {
if(sortField !== "title") { if(sortField !== "title") {
a = self.getTiddler(a).fields[sortField] || 0; a = self.getTiddler(a).fields[sortField] || "";
b = self.getTiddler(b).fields[sortField] || 0; b = self.getTiddler(b).fields[sortField] || "";
} }
if(!isCaseSensitive) { if(!isCaseSensitive) {
a = a.toLowerCase(); a = a.toLowerCase();