Sorting NSArray and returning NSArray?

后端 未结 3 1443
一向
一向 2021-01-21 10:01

I am just looking at sorting an NSArray of NSNumbers into numeric order but am a little unsure of the best way to go. By my way of thinking 001 and 002

相关标签:
3条回答
  • 2021-01-21 10:12

    You don't need a mutable array at all. You can just do:

    NSArray* sortedArray = [arrayNumbers sortedArrayUsingSelector:@selector(compare:)];
    
    0 讨论(0)
  • 2021-01-21 10:22

    NSArray* sortedArray = [arrayNumbers sortedArrayUsingSelector:@selector(compare:)];

    0 讨论(0)
  • 2021-01-21 10:31

    I think you can just call

    return [arrayNumbers sortedArrayUsingSelector:@selector(compare:)];
    
    0 讨论(0)
提交回复
热议问题