I have an array which contains objects some may be same and some are different.
How can I take each same objects and different objects separately ?
Below is the array
NSMutableArray *items = [[NSMutableArray alloc]
initWithArray:[NSArray arrayWithObjects:@"rat", @"rat", @"cat",@"Lion", @"cat", @"dog", @"dog", nil]];
I want to have four arrays which will contains these items :
- First array with two rats
- 2nd array with two cats
- 3rd array with one lion
- 4th array with two dogs
What could be the best way to take the objects out ? Identical object should be placed in same array.