object1.msgTime是获取的时间戳
// 时间排序
-(NSArray*)paixuArr:(NSArray *)arr{
NSArray * array=[arr sortedArrayUsingComparator:^NSComparisonResult(id obj1,id obj2) {
EMConversationModel *object1 = (EMConversationModel *)obj1;
EMConversationModel *object2 = (EMConversationModel *)obj2;
if ([object1.msgTime doubleValue] < [object2.msgTime doubleValue]) {
return NSOrderedDescending;
} else if ([object1.msgTime doubleValue] > [object2.msgTime doubleValue]) {
return NSOrderedAscending;
}
return NSOrderedSame;
}];
return array;
}
网友评论