ios - How to Sort NSMutable Array -


i having nsmutablearray containing objects [1,10,100,101,32a,32b,75,76,77,gaothan], want sort array in ascending order. using below code not working, don't have key in array. if having solution please let me know.

nssortdescriptor *descriptor = [[nssortdescriptor alloc] initwithkey:@"self"                                                             ascending:no]; nsarray *descriptors = [nsarray arraywithobject:descriptor]; nsarray *reverseorder = [datearray sortedarrayusingdescriptors:descriptors]; 

i got it

-(void)sortarray {       nsmutablearray *unsortedarray = [nsmutablearray arraywithobjects:@"1",@"10",@"100",@"32a",@"32b",@"gaothan", nil];     nsarray *sortedarray = [unsortedarray sortedarrayusingcomparator:^(id firstobject, id secondobject)                             {         return [((nsstring *)firstobject) compare:((nsstring *)secondobject) options:nsnumericsearch]; }];     nslog(@"array ::%@",sortedarray); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -