开发者

Sorting NSMutableDictionary data

In my application I am having a dictionary which contains Keys A-Z ie 26 characters which are not in sorted ie for eg A,B,C,...... I want to Sort first The dictionary keys alphabetically and also the sort the data related to each key and then again store that in same dictionary.

NSArray *myKeys = [mGlossaryDic开发者_JAVA技巧t allKeys];
NSArray *op = [myKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

until now here I have an mGlossaryDict which is an Mutabledictionary which is sorted but i need to sort the data from each of the key. Please help me out.


NSArray *myKeys = [mGlossaryDict allKeys];
NSArray *sortedKeys = [myKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
NSMutableArray *sortedValues = [[[NSMutableArray alloc] init] autorelease];

for(id key in sortedKeys) {
    id object = [myGlossaryDict objectForKey:key];
    [sortedValues addObject:object];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜