我有一个对象数组,如:
var temp=
[{Level: "District", Product: "Duplacor", MustBe: "Less Than", Value: 50000},
{Level: "District", Product: "Amcor", MustBe: "Less Than", Value: 100000},
{Level: "District", Product: "Juxtiva", MustBe: "Greater than", Value: 500000},
{Level: "District", Product: "Juxtiva", MustBe: "Less than", Value: 1500000},
{Level: "District", Product: "Amcor", MustBe: "Greater than", Value: 50000}];
我需要像
这样的输出产品MinValue MaxValue
Ex: Juxtiva 500000 1500000
请注意:产品名称不是静态的,它们可能会在后端发生变化,因此我们无法对产品名称进行硬编码,我们必须使用该阵列来检索产品名称(并非全部产品名称将小于,大于值,将至少有一个)
答案 0 :(得分:2)
以下是按产品分组数据的起点,最小值/最大值。输出它应该是微不足道的:
Company.send(:joins, :categories)