I have a NSArray of NSDictionaries, in which I create an NSArray of NSStrings from one of the elements in the NSDictionary.
I am then trying to sort both, but I am getting slightly different results from both sorts.
the NSDictionary is simple
NAME
Number
I am the first NSArray and creating a new NSArray using the NAME element of the dictionary.
I am then sorting the first array like this
NSSortDescriptor * descriptor = [[NSSortDescriptor alloc] initWithKey:@"NAME" ascending:YES]; // 1
sortedByNameArray = [dataArrayOfDictionaries sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
I then take the second array, which is exactly the same order before the first is sorted and sort it like this
// sorts nicknames
newSortedArray = [nameOnlyArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
And although both arrays are sorted alphabetically localizedCaseInsensitiveCompare: seems to do a good job of sorting where as my other sortedArrayUsingDescriptors: only seems to sort using the first letter so its not truly sorted.
I would like some help applying localizedCaseInsensitiveCompare to the NSArray of Dictionaries.. but I am not sure how to do this considering you have to access the NAME element of each NSDictionary inside the first NSArray.
Any help would be greatly appreciated.