in reply to Grouping Multiple Occurences

You may want to rethink your data structure: How do I make a hash of arrays?
Your key is the ID and values are the Classes.