2 local io
= require("io")
3 local table = require("table")
8 local function pushValue(t
, group
, value
)
9 local items
= t
[group
] or {}
11 items
[#items
+ 1] = value
13 for line
in io
.lines() do
14 local author
= line
:match("^(.- %(%d*%):)$")
15 line
= line
:match("^%s*(.-)%s*$")
17 currentAuthor
= authors
[author
] or {}
18 authors
[author
] = currentAuthor
19 elseif currentAuthor
and #line
> 0 then
20 local msg
= line
:gsub("^%s*","")
21 local group
, data
= msg
:match("^([^:]*[%s]*:)[%s]*(.*)$")
23 pushValue(currentAuthor
, "-ungrouped-", msg
)
25 pushValue(currentAuthor
, group
, data
)
29 for author
, groups
in pairs(authors
) do
33 for group
, groupValues
in pairs(groups
) do
34 sorted
[#sorted
+ 1] = {group
, groupValues
}
36 table.sort(sorted
, function(a
,b
) return a
[1] < b
[1] end)
37 for _
, gv
in ipairs(sorted
) do
38 local group
, groupValues
= unpack(gv
)
40 for _
, entry
in ipairs(groupValues
) do
41 print("\t\t" .. entry
)