How Do I sort an NSMutable Array with NSNumbers in it?

后端 未结 7 2084
星月不相逢
星月不相逢 2020-12-05 02:06

I\'m trying to make a high score table, and suck at arrays in objective c (actually, in general objective c is challenging for me), so I can\'t figure out how to sort. I\'m

7条回答
  •  孤街浪徒
    2020-12-05 02:18

    For Descending Order:

    NSArray *DescendingArray = [MinMaxArray sortedArrayUsingDescriptors:
                                    @[[NSSortDescriptor sortDescriptorWithKey:@"doubleValue"
                                                                    ascending:NO]]];
    

    For ascending Order

    NSArray *AscendingArray = [MinMaxArray sortedArrayUsingDescriptors:
                                    @[[NSSortDescriptor sortDescriptorWithKey:@"doubleValue"
                                                                    ascending:YES]]];
    

提交回复
热议问题