HurkNburkS
HurkNburkS

Reputation: 5510

Sort NSArray of NSDictionaries ignore case

I am sorting an NSArray of NSDictionaries which is working using the following code

NSArray *getIndexArray = [nicknamesCombinedArray copy];

            NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"MANUFACTURER"  ascending:YES];
            NSDictionary *sortedGetIndexArray = [getIndexArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];

The only issue is that when it sorts if the word is all CAPS then it sorts like this

JESS
Jack
Jelly
Job

Where I would like it to be

Jack
Jelly
JESS
Job

Upvotes: 0

Views: 64

Answers (1)

RAJA
RAJA

Reputation: 1214

Try this code..

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"MANUFACTURER"  ascending:YES  selector:@selector(localizedCaseInsensitiveCompare:)];

Upvotes: 3

Related Questions