I have an NSArray of NSNumber objects that I have successfully sorted in ascending order using the following:
[myArray sortedArrayU
I have a mutableArray and want to sort in descending order with "number" key. "number" key is a string like "12345", "12346". This way that I had tried and look very well. Hope help you!
NSComparisonResult result;
NSArray *arrTem = [multableArr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
if([obj1 valueForKey:@"number"] > [obj2 valueForKey:@"number"])
result = NSOrderedDescending;
result = NSOrderedSame;
}];
return [[NSMutableArray alloc]initWithArray:arrTem];