I have an array, with some names (String) in it.
1.) I want to list these names in the array in alphabetical order.
2.) Later i will add some more names to this array, so it had to get appended to this array.
How can i do this programatically ?
note: i don’t have any code to demonstrate my working so far. i just have an array created.
EDIT
If my array declaration is ;
NSArray *array = [NSArray arrayWithObjects:@"A",@"C",@"B", @"M",nil];
how can i sort this ?
You should really try getting used to looking at documentation – once you get the hang of it you can figure things out pretty quickly
The docs for NSArray give you the exact way to sort an array:
Now considering you are wanting to add objects later you will most likely use an
NSMutableArraythe docs for NSMutableArray show the method:Therefore you could use
which will sort your array in place resulting in