Вы делаете это неправильно, вы должны использовать componentsSeparatedByString:
и сортировку:
NSString *stringWithNumbersOrdered(NSString *input)
{
static NSArray *numberStrings = nil;
if (!numberStrings)
{
numberStrings = [NSArray arrayWithObjects:@"zero", @"one", @"two", @"three", @"four", @"five", @"six", @"seven", @"eight", @"nine", /* etc. */ nil];
}
NSArray *components = [input componentsSeparatedByString:@" "];
NSArray *componentsSorted = [components sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
int value1 = [numberStrings indexOfObject:obj1];
int value2 = [numberStrings indexOfObject:obj2];
return value1 - value2;
}];
return [componentsSorted componentsJoinedByString:@" "];
}