Creating an overview of grades

Consider a text file representing a list of students among with examination grades ranging from level A to D:

Tim Bone, D
Eve Thunder, A
Aaron King, B
Joan White, B
Mark Singer, C
Jane Simmonds, D
Ethan Clarke, C
Paula Beam, C

Duplicate names may appear.

exercise No. 190

Creating an overview of grades showing frequencies Create comment in forum

Q:

Transform the preceding text file into an overview of grades by aggregating the occurrences of marks. The current example should lead to:

Overview of marks:
A: 1
B: 2
C: 3
D: 2

A:

exercise No. 191

Creating an overview of grades showing individual names Create comment in forum

Q:

Replace the mark frequencies by the actual list of alphabetically sorted names. The current example should lead to:

Overview of marks:
A: Eve Thunder
B: Aaron King, Joan White
C: Ethan Clarke, Mark Singer, Paula Beam
D: Jane Simmonds, Tim Bone

A: