Question: I have two arrays here on is from another class and one i have created in the function, my end goal is to have teamRoster sorted alphabetically, this seems to work but could someone please tell me if there is a better way? Thanks.

```
-(IBAction)submitAndSendBack:(id)sender{
        CoCoachAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

        NSString *fullName = [ NSString stringWithFormat:@"%@ %@",firstName.text, lastName.text];   
        [[appDelegate teamRoster] addObject:fullName];
        NSArray *temp = [[appDelegate teamRoster] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

        [[appDelegate teamRoster] removeAllObjects];
        [[appDelegate teamRoster] addObjectsFromArray:temp];

        NSLog(@"%@", [appDelegate teamRoster]);

        [ap

pDelegate.navigationController popViewControllerAnimated:YES];
}

```

Answer: 
Is there a better way? Depends on what you mean by "better".

Your code is correct and easy enough to understand.

Assuming `teamRoster` is a property of type `NSMutableArray`, you could simply sort it in place:

```
[[appDelegate teamRoster] sortUsingSelector:@selector(caseInsensitiveCompare:)];

```

But there might be reasons NOT to do it that way, say for performance or concurrency.

On the other hand, you might want to protect the `teamRoster` array from being modified by code outside of the app delegate, in which case you should only make it available as an immutable NSArray, and you wouldn't be able to use the above to sort it.
Try this:

```
appDelegate.teamRoster = [[temp mutableCopy] autorelease];

```

That is assuming you have a property setup that allows you to change teamRoster.