Asked 30+ days ago
18 Feb 2017
Views 242
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 Jan 23 '18 20:17


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:
Edit Answer
Share
Post Answer