Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
t = File.read("x")[/------$\n(.*)--$/m, 1]

i = {}

t.split(/\n\n+/).each { |entry|
  a, *ms = entry.split(/\s{2,}|\t/)
  ms.each { |m| (i[m] ||= []) << a }
}

i.keys.sort.each { |m|
  puts m
  i[m].each { |a| puts "\t#{a}" }
}