1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +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) {
var aa = a.fields[sortField].toLowerCase() || 0,
bb = b.fields[sortField].toLowerCase() || 0;
var aa = a.fields[sortField].toLowerCase() || "",
bb = b.fields[sortField].toLowerCase() || "";
if(aa < bb) {
return -1;
} else {
@ -247,8 +247,8 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive) {
var self = this;
titles.sort(function(a,b) {
if(sortField !== "title") {
a = self.getTiddler(a).fields[sortField] || 0;
b = self.getTiddler(b).fields[sortField] || 0;
a = self.getTiddler(a).fields[sortField] || "";
b = self.getTiddler(b).fields[sortField] || "";
}
if(!isCaseSensitive) {
a = a.toLowerCase();