How to sort an array of dates in descending order

前端 未结 6 1303
囚心锁ツ
囚心锁ツ 2020-12-16 14:31

I have a NSDictionary that parsed to an array one of the element is date, i tried using [startimeArray sortUsingSelector:@selector(compare:)]; (starttimeArray)

6条回答
  •  一整个雨季
    2020-12-16 15:19

    Sort the array by puting NO is ascending parameter:

    NSSortDescriptor *descriptor=[[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO];
    NSArray *descriptors=[NSArray arrayWithObject: descriptor];
    NSArray *reverseOrder=[dateArray sortedArrayUsingDescriptors:descriptors];
    

提交回复
热议问题