implemented buy grouping

This commit is contained in:
Manuel Simon Hirsig
2015-10-20 02:06:07 +02:00
parent 6a473629e2
commit 1b9da9c1ad
4 changed files with 110 additions and 113 deletions
+8 -5
View File
@@ -238,14 +238,17 @@ end
function Aux.util.group_by(tables, keys)
local groups = {}
Aux.util.map(tables, function(table)
for _, table in ipairs(tables) do
local found_group
for _, group in ipairs(groups) do
if Aux.util.all(keys, function(key) return table[key] == group[1][key] end) then
tinsert(group, table)
return
found_group = true
end
end
tinsert(groups, { table })
end)
end
if not found_group then
tinsert(groups, { table })
end
end
return groups
end