NSSortDescriptor作用

来源:互联网 发布:vero moda淘宝旗舰店 编辑:程序博客网 时间:2024/05/17 07:07
    NSArray *ma1 = @[@"1",@"3",@"2",@"5",@"4"];        NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending:NO];    NSArray *arr1 = [ma1 sortedArrayUsingDescriptors:@[sort]];    NSLog(@"%@",arr1);//    5,//    4,//    3,//    2,//    1


NSSortDescriptor 用于排序


1传递的key是KVC机制, 可以加上'.'

2ascending控制升序降序.