NSMutableArray *dataArray = [NSMutableArray array];
[fetchResult enumerateObjectsWithOptions:NSEnumerationReverse
usingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {
[dataArray addObject:asset];
}];
if (dataArray.count > 0) {
[dataArray enumerateObjectsUsingBlock:^(PHAsset* asset, NSUInteger idx, BOOL * _Nonnull stop) {
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"yyyy/MM/dd"];
NSString *destDateString = [dateFormatter1 stringFromDate:asset.creationDate];
NSLog(@"%@",destDateString);
}];
[dataArray sortUsingComparator:^NSComparisonResult(PHAsset* asset1, PHAsset* asset2) {
return [asset2.creationDate compare:asset1.creationDate];
}];
NSLog(@"compareEnd");
[dataArray enumerateObjectsUsingBlock:^(PHAsset* asset, NSUInteger idx, BOOL * _Nonnull stop) {
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"yyyy/MM/dd"];
NSString *destDateString = [dateFormatter1 stringFromDate:asset.creationDate];
NSLog(@"%@",destDateString);
}];