Fix problem with sorting missing tiddlers

Fixes #858
This commit is contained in:
Jermolene 2014-09-17 12:17:43 +01:00
parent 1b0eec143e
commit 8cc236b4dc
1 changed files with 12 additions and 2 deletions

View File

@ -317,8 +317,18 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,is
var self = this;
titles.sort(function(a,b) {
if(sortField !== "title") {
a = self.getTiddler(a).fields[sortField] || "";
b = self.getTiddler(b).fields[sortField] || "";
var tiddlerA = self.getTiddler(a),
tiddlerB = self.getTiddler(b);
if(tiddlerA) {
a = tiddlerA.fields[sortField] || "";
} else {
a = "";
}
if(tiddlerB) {
b = tiddlerB.fields[sortField] || "";
} else {
b = "";
}
}
if(isNumeric) {
a = Number(a);