well it depends on if you do more inserting or more reading...
if you do a lot of inserting and not a lot of reading, then you could sort lazily...
both of these examples require you to define -(NSComparisonResult)compareColor:(id)someOtherColor
...
you could also use a block or function.
- (NSArray *)colors
{
return [_colors sortedArrayUsingSelector:@selector(compareColor:) ];
}
or you could sort up front on insert, if you read more frequently
- (void)addColor:(Color *)color
{
NSMutableArray *mutableColors = [self.colors mutablecopy];
[mutableColors addObject:color];
self.colors = [mutableColors sortedArrayUsingSelector:@selector(compareColor:)];
}