Think Inception. Say I have 2 objects A
and B
and each instance of A
has a variable B
and each B
has an NSNumber
variable.
I have an NSArray Array
with instances of A
inside it and I want to sort it based on the NSNumber
variable within B. So the normal approach of going
NSArray *array = [[NSArray alloc] initWithObjects:a1,a2,a3,a4,a5,nil];
NSSortDescriptor* sortOrder = [NSSortDescriptor sortDescriptorWithKey: @"b" ascending: YES];
array = [array sortedArrayUsingDescriptors: [NSArray arrayWithObject:sortOrder]];
just isn't going to cut it. Any ideas?