Last active
August 29, 2015 14:02
-
-
Save alco/b1e8785dcac7b16d041e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iPhone OS programming circa 2008 | |
// ================================ | |
NSInteger fruitSorter(NSString *a, NSString *b, void *context) { | |
return [a compare:b]; | |
} | |
// ... | |
NSMutableArray *fruits = [[NSMutableArray alloc] initWithObjects:@"apple", @"pear", @"banana", nil]; | |
[fruits sortUsingFunction:fruitSorter context:NULL]; | |
// iOS programming circa 2013 | |
// ========================== | |
NSMutableArray *fruits = @[@"apple", @"pear", @"banana"]; | |
[fruits sortUsingComparator:^(NSString *a, NSString *b) { return [a compare:b]; }]; | |
// iOS programming circa 2014 | |
// ========================== | |
var fruits = ["apple", "pear", "banana"] | |
fruits.sort{ $0 < $1 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment