I have a list of objects which contain several properties. I am looking to break the list into several lists composed of objects which posses the same sub-property.
Here is a hypothetical example, say I have a list of Cars
. Each Car
has properties: id
, manufacturerId
and color
.
I would like to create lists of Cars
for those with matching manufacturerId
properties.
I have tried using list.where
within list.forEach
to create new sub-lists, however I get duplicate lists because when the property I am comparing against (A) matches with another property (B), I get another sub-list when:
B = A.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…