6 local function pushValue(t
, group
, value
)
7 local items
= t
[group
] or {}
9 items
[#items
+ 1] = value
11 for line
in io
.lines() do
12 local author
= line
:match("^(.- %(%d*%):)$")
13 line
= line
:match("^%s*(.-)%s*$")
15 currentAuthor
= authors
[author
] or {}
16 authors
[author
] = currentAuthor
17 elseif currentAuthor
and #line
> 0 then
18 local msg
= line
:gsub("^%s*","")
19 local group
, data
= msg
:match("^([^:]*[%s]*:)[%s]*(.*)$")
21 pushValue(currentAuthor
, "-ungrouped-", msg
)
23 pushValue(currentAuthor
, group
, data
)
27 for author
, groups
in pairs(authors
) do
31 for group
, groupValues
in pairs(groups
) do
32 sorted
[#sorted
+ 1] = {group
, groupValues
}
34 table.sort(sorted
, function(a
,b
) return a
[1] < b
[1] end)
35 for _
, gv
in ipairs(sorted
) do
36 local group
, groupValues
= unpack(gv
)
38 for _
, entry
in ipairs(groupValues
) do
39 print("\t\t" .. entry
)