I am currently using NSMutableArrays in my designs to store some data taken from an HTTP servlet.
Everything is in order, since now I have to sort what is in my array.
This is what I do:
NSMutableArray *array = [[NSMutableArray arrayWithObjects:nil] retain]; [array addObject:[NSArray arrayWithObjects: "Label 1", 1, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 2", 4, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 3", 2, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 4", 6, nil]]; [array addObject:[NSArray arrayWithObjects: "Label 5", 0, nil]];
The first column contains the label, and the second contains the rating. I want the array to be sorted in descending order.
Am I storing my data so well? Is there a better way to do this than using NSMutableArrays in NSMutableArray ?
I am new to iPhone dev, I saw some sorting code, but didn't feel good.
Thanks in advance for your answers!
sorting objective-c nsmutablearray
Donut
source share