From 4c78d3dc5116d4fbf1f146019ef425e6f2f1a50a Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Wed, 12 Dec 2012 12:00:38 -0800 Subject: [PATCH] Make sub-key sort check for undefined before dereferencing. This way it doesn't throw when given an object that doesn't contain all the keys being searched on. --- packages/minimongo/sort.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/minimongo/sort.js b/packages/minimongo/sort.js index 9cd73e3327..53114153dc 100644 --- a/packages/minimongo/sort.js +++ b/packages/minimongo/sort.js @@ -11,8 +11,6 @@ // first object comes first in order, 1 if the second object comes // first, or 0 if neither object comes before the other. -// XXX sort does not yet support subkeys ('a.b') .. fix that! - LocalCollection._compileSort = function (spec) { var keys = []; var asc = []; @@ -44,16 +42,22 @@ LocalCollection._compileSort = function (spec) { var _func; var code = "_func = (function(c){return function(a,b){var x;"; for (var i = 0; i < keys.length; i++) { - var splittedKeys = keys[i].split("."); - var keyString = ""; - for(o = 0;o