Objective-C 对字符串数组排序

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSArray* array = [NSArray arrayWithObjects:@"RaspBerry", @"Peach", @"Banana", @"BlackBerry", @"BlueBerry", @"Apple", nil];
        NSLog(@"%@", array);
        
        NSArray* arraySorted = [array sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
        NSLog(@"%@", arraySorted);
    }
    return 0;
}



你可能感兴趣的:(Objective-C 对字符串数组排序)