It's not clear to me what the types of the objects in the array are so you'll need to change the following code to fit with your types, but this is generally how you would sort an array:
NSMutableArray* array = [[NSMutableArray alloc] init];
[array addObject:@"3.value"];
[array addObject:@"1.value"];
[array addObject:@"4.value"];
[array addObject:@"2.value"];
NSArray* sortedArray = [array sortedArrayUsingComparator: ^(id obj1, id obj2) {
// Write whatever comparison code is appropriate for your objects here
// The following will only work for simple strings
return [obj1 caseInsensitiveCompare:obj2];
}];
NSLog(@"%@", sortedArray);
EDIT:
If you're using strings and the strings are always formatted so that they take the form: "Integer.String" you should use the following code to sort your array:
NSArray* sortedArray = [array sortedArrayUsingComparator: ^(id obj1, id obj2) {
NSInteger left = [obj1 integerValue];
NSInteger right = [obj2 integerValue];
if (left > right) {
return NSOrderedDescending;
}
if (left < right) {
return NSOrderedAscending;
}
return NSOrderedSame;
}];
If you just compare strings they will be sorted by their first character so @"123.value" will come before "9.value"