minor changes in sortBy
This commit is contained in:
parent
27d37ea601
commit
b28eb7ec51
1 changed files with 4 additions and 3 deletions
|
@ -487,14 +487,15 @@ Ox.range = function() {
|
|||
[{id: 1, name: '8 Women'}, {id: 0, name: '80 Days'}]
|
||||
@*/
|
||||
Ox.sortBy = function(arr, by, fn) {
|
||||
var length = by.length, values = {};
|
||||
var values = {};
|
||||
by = Ox.toArray(by);
|
||||
fn = fn || {};
|
||||
by = by.map(function(v) {
|
||||
return Ox.isString(v) ? {
|
||||
key: v.replace(/^[\+\-]/, ''),
|
||||
operator: v[0] == '-' ? '-' : '+'
|
||||
} : v;
|
||||
});
|
||||
fn = fn || {};
|
||||
by.map(function(v) {
|
||||
return v.key;
|
||||
}).forEach(function(key) {
|
||||
|
@ -504,7 +505,7 @@ Ox.range = function() {
|
|||
});
|
||||
return arr.sort(function(a, b) {
|
||||
var aValue, bValue, index = 0, key, ret = 0;
|
||||
while (ret == 0 && index < length) {
|
||||
while (ret == 0 && index < by.length) {
|
||||
key = by[index].key;
|
||||
aValue = values[key][a[key]];
|
||||
bValue = values[key][b[key]];
|
||||
|
|
Loading…
Reference in a new issue