You can use a "sorted" NSMutableArray and it would hold your 27 "letter" NSMutableArray objects that each hold your objects.
You can also use an NSArray of the 26 letters (as NSString objects) and use indexOfObject:
to get the index from the "sorted" array of the "letter" array that object should be added to (if it returns NSNotFound, use 26 as the index since that's your non-alpha array).
For example, if you are sorting NSString objects, you could do it like this:
NSArray *originalArray = [NSArray arrayWithObjects:@"A object",@"B object",@"C object",@"123 object",nil];
// init with all 26 lowercase letters here
NSArray *letters = [NSArray arrayWithObjects:@"a",@"b",@"c",nil];
// create sorted and letter arrays
NSMutableArray *sortedArray = [[NSMutableArray alloc] initWithCapacity:[letters count]+1];
for (int i = 0; i < [letters count] + 1; i++) {
// use an appropriate capacity here
NSMutableArray *letterArray = [[NSMutableArray alloc] initWithCapacity:10];
[sortedArray addObject:letterArray];
[letterArray release];
}
// sort originalArray into sortedArray
for (NSString *string in originalArray) {
NSString *firstLetter = [[string substringWithRange:[string rangeOfComposedCharacterSequenceAtIndex:0]] lowercaseString];
int index = [letters indexOfObject:firstLetter];
if (index == NSNotFound) {
// use non-alpha array
index = [letters count];
}
NSMutableArray *letterArray = [sortedArray objectAtIndex:index];
[letterArray addObject:string];
}
NSLog(@"%@",sortedArray);