So, imagine that you have several arrays, colors, and shapes, for example:
Colors: {
Yellow,
Blue,
Red
}
Shapes: {
Square,
Circle,
Diamond
}
Now, if I want to sort the colors alphabetically, I can do something like this:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
NSArray *sortedColors = [colors sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];
But how would I sort the shapes in the order in which I re-ordered Colors. I do not mean that Shapes are in alphabetical order - I mean that Shapes are in alphabetical order of colors ...?
source
share