Map
Map with List by Key
✅
Map<String, List<SObject>> industryToAccounts = new Map<String, List<SObject>>();
for (Account acc : [SELECT Id, Industry FROM Account]) {
if (!industryToAccounts.containsKey(acc.Industry)) {
industryToAccounts.put(acc.Industry, new List<SObject>());
}
industryToAccounts.get(acc.Industry).put(acc);
}