I have an NSArray containing 6x 3D arrays with image pixel data, and an NSMutableArray with 6 values. I would like to sort the NSMutableArray array numerically and sort the NSArray in the same order that the NSMutableArray is sorted. I know how to do this in python but I am not great with Objective-C
i.e.,: from: NSArray = [img1, img2, img3] NSMutableArray = [5, 1, 9] to: NSArray = [img2, img1, img3] NSMutableArray = [1, 5, 9]
NSArray *imageArray = [...some images];
NSMutableArray *valueList = [[NSMutableArray alloc] initWithCapacity:0];
float value1 = 5.0;
float value2 = 1.0;
float value3 = 9.0;
[valueList addObject:[NSDecimalNumber numberWithFloat:value1]];
[valueList addObject:[NSDecimalNumber numberWithFloat:value2]];
[valueList addObject:[NSDecimalNumber numberWithFloat:value3]];
img1is linked to value5, it might be better to use aNSDictionary(or customClass) and an array of them instead. That would avoid you that each time the order is changed, an element is changed to reflect the action on the second array.