数组排序

NSArray *array = @[@"John Appleseed", @"Tim Cook", @"Hair Force One", @"Michael Jurewitz"];

    NSArray *sortedArray = [array sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];

    NSLog(@"sortedArray == %@",sortedArray);

    

    NSArray *numbers = @[@9, @5, @11, @3, @1];

    NSArray *sortedNumbers = [numbers sortedArrayUsingSelector:@selector(compare:)];

    NSLog(@"sortedNumbers == %@",sortedNumbers);

posted on 2016-04-15 18:46  哈利波特大  阅读(207)  评论(0)    收藏  举报