From 8cc236b4dca96327c7b28ad45e1eb4c2dce174e5 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 17 Sep 2014 12:17:43 +0100 Subject: [PATCH] Fix problem with sorting missing tiddlers Fixes #858 --- core/modules/wiki.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 1c6263da9..1f4bed260 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -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);