Asked 7 years ago
18 Feb 2017
Views 1504
jaman

jaman posted

how to sort NSArray in objective c ?


    NSString *first =@"nirst";
    NSString *second = @"jecond";
    NSString *third =@"third";
    NSArray *data =[NSArray arrayWithObjects: first,second,third, nil ];


how to sort NSArray ascending order or descending order in objective c ?
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00


NSString *first =@"nirst";
    NSString *second = @"jecond";
    NSString *third =@"third";
    NSArray *data =[NSArray arrayWithObjects: first,second,third, nil ];
    NSArray *sortedata ;
    sortedata = [data sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];


sortedArrayUsingSelector :: sort array’s elements in ascending order
selector can be compare: , localizedCaseInsensitiveCompare: , localizedCompare: , caseInsensitiveCompare:
Post Answer