Group Objects by Common Key
- by Marshmellow1328
I have a list of Customers. Each customer has an address and some customers may actually have the same address. My ultimate goal is to group customers based on their address. I figure I could either put the customers in some sort of list-based structure and sort on the addresses, or I could drop the objects into some sort of map that allows multiple values per key.
I will now make a pretty picture:
List:
A1 - C1, A1 - C2, A2 - C3, A3 - C4, A3 - C5
Map:
A1 A2 A3
C1 C3 C4
C2 C5
Which option (or any others) do you see as the best solution? Are there any existing classes that will make development easier?