fix sorting with undefined in memory connector
This commit is contained in:
parent
efe4601fdb
commit
a6b8ca70af
|
@ -348,9 +348,14 @@ Memory.prototype.all = function all(model, filter, callback) {
|
||||||
|
|
||||||
function sorting(a, b) {
|
function sorting(a, b) {
|
||||||
for (var i = 0, l = this.length; i < l; i++) {
|
for (var i = 0, l = this.length; i < l; i++) {
|
||||||
if (a[this[i].key] > b[this[i].key]) {
|
|
||||||
|
if(a[this[i].key] === undefined && b[this[i].key] === undefined) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b[this[i].key] === undefined || a[this[i].key] > b[this[i].key]) {
|
||||||
return 1 * this[i].reverse;
|
return 1 * this[i].reverse;
|
||||||
} else if (a[this[i].key] < b[this[i].key]) {
|
} else if (a[this[i].key] === undefined || a[this[i].key] < b[this[i].key]) {
|
||||||
return -1 * this[i].reverse;
|
return -1 * this[i].reverse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue