Sorting Array in increasing order

前端 未结 7 427
鱼传尺愫
鱼传尺愫 2021-01-03 07:01

I have an array that contains values like 0,3,2,8 etc.I want to sort my array in increasing order.Please tell me how to do this.

Thanks in advance!!

7条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 07:21

    NSSortDescriptor *sortDescriptor;
    sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:nil
                                                  ascending:YES] autorelease];
    NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
    NSArray *sortedArray;
    sortedArray = [**YourArray** sortedArrayUsingDescriptors:sortDescriptors];
    

提交回复
热议问题