I have an object array (foreign key being classId):
let studentArray = [Student(id:3, name:"John", classId:1), Student(id:4, name:"Jane", classId:1), Student(id:5, name:"Bill", classId:2)]
I am trying to map it to a dictionary with key of classId that looks like this:
[1:[Student], 2:[Student]]
Is there a good way to do this using a dictionary? My solution was to use a for loop to iterate through the array and add each object to the dictionary, but this seems inefficient.