iphone之NSArray比较大小
//排序 NSArray *tempArray = [[NSArray alloc]initWithArray:self.contentArray]; tempArray = [tempArray sortedArrayUsingComparator:^NSComparisonResult(NewCenter *newCenter1, NewCenter *newCenter2) { NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; NSDate *date1 = [formatter dateFromString:newCenter1.newtime]; NSDate *date2 = [formatter dateFromString:newCenter2.newtime]; int i = [date1 compare:date2]; return -i; }];
NewCenter是自定义的类