I am having a problem regarding sorting an array w.r.t database:
NSSortDescriptor *sorter = [[NSSortDescriptor alloc] initWithKey:@\"w\" ascending:YES];
NSAr
I think this will do the trick for you. The docs for it are here: String Programming Guide
Add this little function written by Apple.
int finderSortWithLocale(id string1, id string2, void *locale)
{
static NSStringCompareOptions comparisonOptions =
NSCaseInsensitiveSearch | NSNumericSearch |
NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSRange string1Range = NSMakeRange(0, [string1 length]);
return [string1 compare:string2
options:comparisonOptions
range:string1Range
locale:(NSLocale *)locale];
}
Make sure that you copy the function definition into your header, or you'll get a compile error on your sorted array.
For your sorted array, use this method:
[mGlossaryArray sortedArrayUsingFunction:finderSortWithLocale context:[NSLocale currentLocale]];
Your results will look like this: