I\'m trying to make a high score table, and suck at arrays in objective c (actually, in general objective c is challenging for me), so I can\'t figure out how to sort. I\'m
For all it's worth, here is another shorthand method:
NSArray* n = @[@8, @3, @1, @12, @16, @7, @0, @5];
NSArray* asc = [n sortedArrayUsingComparator:^NSComparisonResult(NSNumber* n1, NSNumber* n2) {
return [n1 compare:n2];
}];
NSLog(@"Ascending: %@", asc);
NSArray* dec = [n sortedArrayUsingComparator:^NSComparisonResult(NSNumber* n1, NSNumber* n2) {
return [n2 compare:n1];
}];
NSLog(@"Descending: %@", dec);