我有一个列表列表,我想按市场名称和商品名称分组,按列出价格:例如 ["Terra", "Wheat", 1000.0] - "Terra" 是市场名称,"Wheat" 是商品名称,1000.0 是价格
def marketCommodityGroup = [
["Merkato", "Wheat", 1000.0],
["Shola", "Wheat", 1875.0],
["Merkato", "Barley", 5000.0],
["Merkato", "Wheat", 1000.0],
["Merkato", "Wheat", 1500.0]
]
我希望输出为:
[
["Merkato": ["Wheat" : [1000.0, 1000.0, 1500.0]]],
["Merkato": ["Barley": [5000.0]]],
["Shola": ["Wheat": [1875.0]]]
]