开发者

Sorting NSMutableArray with NSStrings in alphabetical order

开发者 https://www.devze.com 2023-02-23 08:11 出处:网络
I have a NSMutableArray with NSStrings and I want t开发者_StackOverflow社区o sort them in alphabetical order, seems it\'s no hard, but I didn\'t find nice solution. Help me please.Using sortUsingSelec

I have a NSMutableArray with NSStrings and I want t开发者_StackOverflow社区o sort them in alphabetical order, seems it's no hard, but I didn't find nice solution. Help me please.


Using sortUsingSelector: method with compare: as comparing selector:

NSMutableArray* strings = [NSMutableArray arrayWithObjects:@"dog", @"ant", @"cat",nil];
[strings sortUsingSelector:@selector(compare:)];
NSLog(@"%@", strings);
0

精彩评论

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