我正在使用下划线 js,并且我有一个对象数组。
[{"a":"j1","b":1,"c":1,"life":1},{"a":"j2","b":5,"c":7,"life":5},{"a":"j3","b":9,"c":0,"life":9},{"a":"j4","b":4,"c":1,"life":4}]
我想获取在b
和处属性值最小的对象的索引c
。b
如果有共享相同的对象,我只想获取每个对象的 1 个c
我有这些递归函数
groupByMulti: (obj, values, context) ->
if (!values.length)
return obj;
byFirst = _.groupBy(obj, values[0], context)
rest = values.slice(1)
for i in byFirst
byFirst[i] = groupByMulti(byFirst[i], rest, context)
return byFirst