//create_time 降序 NSComparisonResult sort_desc(NSDictionary *firstDict, NSDictionary *secondDict, void *context) { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; long a = (long) [[dateFormatter dateFromString:[firstDict objectForKey:@"create_time"]] timeIntervalSince1970] * 1000; long b = (long) [[dateFormatter dateFromString:[secondDict objectForKey:@"create_time"]] timeIntervalSince1970] * 1000; if (a >= b) return NSOrderedAscending; else return NSOrderedDescending; } //调用 NSArray *array = [self.arr copy]; array = [array sortedArrayUsingFunction:sort_desc context:NULL];
标签:dateFormatter,create,Object,IOS,NSDictionary,long,time,array From: https://www.cnblogs.com/IBPM/p/17054882.html