有一个NSDictionary解析到数组,其中一个元素是日期。使用[startimeArray sortUsingSelector:@selector(compare:)];
后只能进行升序排列,如何进行降序排列?
非常感谢。
NSSortDescriptor *sortDes=[[NSSortDescriptor alloc] initWithKey:@"存储日期的key" ascending:NO];
startimeArray =[startimeArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sortDes,nil]];
NSLog(@"sort array :%@",startimeArray );
进行如下设置:
NSSortDescriptor *descriptor=[[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO];
NSArray *descriptors=[NSArray arrayWithObject: descriptor];
NSArray *reverseOrder=[dateArray sortedArrayUsingDescriptors:descriptors];