美文网首页
字符串数组排序

字符串数组排序

作者: 白菜松 | 来源:发表于2016-12-07 00:24 被阅读13次

    字符串数组排序

    NSArray *charArray = @[@"string 1",@"String 21",@"string 12",@"String 11",@"String 02"];
        NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch|NSNumericSearch|
        NSWidthInsensitiveSearch|NSForcedOrderingSearch;
        NSComparator sort = ^(NSString *obj1,NSString *obj2){
            NSRange range = NSMakeRange(0,obj1.length);
            return [obj1 compare:obj2 options:comparisonOptions range:range];
        };
        NSArray *resultArray2 = [charArray sortedArrayUsingComparator:sort];
        NSLog(@"字符串数组排序结果%@",resultArray2);
    

    相关文章

      网友评论

          本文标题:字符串数组排序

          本文链接:https://www.haomeiwen.com/subject/malsuttx.html