modify Ox.sort so that empty, null or undefined volumes come last, regardless of sort order (fixes # 727)
This commit is contained in:
parent
4a09d329c8
commit
b03393bc0c
1 changed files with 20 additions and 8 deletions
|
@ -246,7 +246,7 @@ Ox.api = function(items, options) {
|
||||||
};
|
};
|
||||||
} else if (Ox.isArray(items[0][key])) {
|
} else if (Ox.isArray(items[0][key])) {
|
||||||
sort[key] = function(value) {
|
sort[key] = function(value) {
|
||||||
return value.join(', ')
|
return value.join(', ');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -399,15 +399,24 @@ Ox.range = function() {
|
||||||
// pad leading numbers, make lowercase,
|
// pad leading numbers, make lowercase,
|
||||||
// and remove leading non-word characters
|
// and remove leading non-word characters
|
||||||
arr.forEach(function(val, i) {
|
arr.forEach(function(val, i) {
|
||||||
sort[val] = Ox.isString(arr_[i])
|
var val_ = arr_[i];
|
||||||
? (
|
if (
|
||||||
|
Ox.isEmpty(val_)
|
||||||
|
|| Ox.isNull(val_)
|
||||||
|
|| Ox.isUndefined(val_)
|
||||||
|
) {
|
||||||
|
sort[val] = null;
|
||||||
|
} else if (Ox.isString(val_)) {
|
||||||
|
sort[val] = (
|
||||||
matches[val]
|
matches[val]
|
||||||
? arr_[i].replace(
|
? val_.replace(
|
||||||
matches[val], Ox.pad(matches[val], len)
|
matches[val], Ox.pad(matches[val], len)
|
||||||
)
|
)
|
||||||
: arr_[i]
|
: val_
|
||||||
).toLowerCase().replace(/^\W+/, '')
|
).toLowerCase().replace(/^\W+/, '');
|
||||||
: arr_[i];
|
} else {
|
||||||
|
sort[val] = val_;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return sort;
|
return sort;
|
||||||
}
|
}
|
||||||
|
@ -465,13 +474,16 @@ Ox.range = function() {
|
||||||
return v[key];
|
return v[key];
|
||||||
}), fn[key]);
|
}), fn[key]);
|
||||||
});
|
});
|
||||||
|
Ox.print('VALS::::', values)
|
||||||
return arr.sort(function(a, b) {
|
return arr.sort(function(a, b) {
|
||||||
var aValue, bValue, index = 0, key, ret = 0;
|
var aValue, bValue, index = 0, key, ret = 0;
|
||||||
while (ret == 0 && index < length) {
|
while (ret == 0 && index < length) {
|
||||||
key = by[index].key;
|
key = by[index].key;
|
||||||
aValue = values[key][a[key]];
|
aValue = values[key][a[key]];
|
||||||
bValue = values[key][b[key]];
|
bValue = values[key][b[key]];
|
||||||
if (aValue < bValue) {
|
if ((aValue === null) != (bValue === null)) {
|
||||||
|
ret = aValue === null ? 1 : -1;
|
||||||
|
} else if (aValue < bValue) {
|
||||||
ret = by[index].operator == '+' ? -1 : 1;
|
ret = by[index].operator == '+' ? -1 : 1;
|
||||||
} else if (aValue > bValue) {
|
} else if (aValue > bValue) {
|
||||||
ret = by[index].operator == '+' ? 1 : -1;
|
ret = by[index].operator == '+' ? 1 : -1;
|
||||||
|
|
Loading…
Reference in a new issue