Skip to content

Commit

Permalink
Added sorting functionality for 'a.b'
Browse files Browse the repository at this point in the history
  • Loading branch information
lvbreda authored and n1mmy committed Dec 17, 2012
1 parent c10dd19 commit bd94569
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/minimongo/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ 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++) {
if (i !== 0)
code += "if(x!==0)return x;";
code += "x=" + (asc[i] ? "" : "-") +
"c(a[" + JSON.stringify(keys[i]) + "],b[" +
JSON.stringify(keys[i]) + "]);";
var splittedKeys = keys[i].split(".");
var keyString = "";
for(o = 0;o<splittedKeys.length;o++){
keyString = keyString + "["+ JSON.stringify(splittedKeys[o]) +"]";
}
if (i !== 0){
code += "if(x!==0)return x;";
}
code += "x=" + (asc[i] ? "" : "-") +
"c(a" + keyString +",b"+keyString+");";
}
code += "return x;};})";

eval(code);
return _func(LocalCollection._f._cmp);
};

0 comments on commit bd94569

Please sign in to comment.