Sorting an array of NSNumber elements in Objective-C is fairly straight forward: NSArray *unsortedArray = @[@(9), @(5), @(1), @(2), @(4)]; NSArray *sortedArray = [unsortedArray sortedArrayUsingSelector:@selector(compare:)]; NSLog(@"sortedArray: %@", sortedArray); But what happens if we have something more complex, where the value being compared isn't the type itself but a property of that type? The simple approach above won't work. Instead, we need to use a NSSortDescriptor. NSSortDescriptor allows us to…
#sorting
One post with this tag