Q:

How to sort a stringsarray that contain numbers and names in iOS

I got an array that contains strings and want to sort it.
So far, so easy. 
I simply use 
NSSortDescriptor *sort [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
[list sortUsingDescriptors:[NSArray arrayWithObject:sort] ];

The problem here is, that when I use it for a list like "ccccc, aab, bba, 123"
he sorts it to "123, aab, bba, ccccc".
I would like to sort it like "aab, bba, ccccc, 123"
Is there an iOS-function to sort it that numbers are put at the end of the list? The numbers are ofc also strings.
Thanks for any help guys.

A:

It's conventional for numbers to be put before letters in a standard sort.  If you want the numbers last, you will have to do some manipulation.
You can use an NSPredicate to get just the numbers in one array, then just the letters in another array, then finally combine them to get the numbers at the end.
// Get just the letters
NSPredicate *predLetters = [NSPredicate predicateWithFormat:@"name MATCHES %@",@"^\\p{letter}.*"];
NSArray *tempLetters = [[list copy] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
tempLetters = [tempLetters filteredArrayUsingPredicate:predLetters];

// Get just the numbers
NSPredicate *predNumbers = [NSPredicate predicateWithFormat:@"NOT (name MATCHES %@)",@"^\\p{letter}.*"];
NSArray *tempNumbers = [[list copy] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
tempNumbers = [tempNumbers filteredArrayUsingPredicate:predNumbers];

// Combine arrays
NSMutableArray *tempCombined = [[NSMutableArray alloc] initWithArray:tempLetters];
[tempCombined addObjectsFromArray:tempNumbers];

// Rename to 'list'
list = [tempCombined copy];

Clarification: This code only works based on the first character of name.  I'm assuming from your question that you won't have any names that have both letters and numbers.  If you do, then the filter will just go off the first character, and the rest of the characters in name will be sorted according to standard convention.  You will probably have to set up a recursive function or something to deal with sorting a name that contains both letters and numbers if you want the letters to always be handled first, even if they are the 5th character in the string, for example.
EDIT: Thanks to @Nerethar for syntax fixes.

