开发者

How to sort an NSMutableArray List of names in alphabetical order in Objective-C?

开发者 https://www.devze.com 2022-12-26 20:35 出处:网络
I need to display the list of names which I am getting from the parser. I am getting the NSMu开发者_如何学Pythontable arrary of list, then i need to display them in alphabetical order.

I need to display the list of names which I am getting from the parser. I am getting the NSMu开发者_如何学Pythontable arrary of list, then i need to display them in alphabetical order.

I tried doing what is given as:

NSArray *myArtistArray=[[NSArray alloc]init];
myArtistArray=[artistsList sortUsingSelector:@selector(compare:) ];

// error void value not ignored as it outght to be
[myArtistArray sortedArrayUsingSelector:@selector(compare:)];


[yourMutableArray sortUsingSelector:@selector(compare:)];
[yourArray sortedArrayUsingSelector:@selector(compare:)];


[yourMutableArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];


  NSArray *arraysort=[[NSArray alloc] initWithObjects:@"z",@"v",@"a",@"g",@"b", nil];
 NSArray   *sortedArray = [arraysort sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
    for (NSString *str in sortedArray) {
        NSLog(@"string %@ ",str);
    }
    NSLog(@"sortedarrayelements %d",[sortedArray count]);


[yourArrayName sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
0

精彩评论

暂无评论...
验证码 换一张
取 消