Created
March 16, 2012 10:03
-
-
Save ashtom/2049389 to your computer and use it in GitHub Desktop.
Sort by pubDate
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
#import <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSDictionary *one = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1], @"pubDate", nil]; | |
NSDictionary *two = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:2], @"pubDate", nil]; | |
NSDictionary *three = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:3], @"pubDate", nil]; | |
NSArray *array = [NSArray arrayWithObjects:three, one, two, nil]; | |
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"pubDate" ascending:YES] autorelease]; | |
NSLog(@"%@", [array sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]); | |
[pool drain]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment