how can I sort NSMutableDictionary with keys value?

后端 未结 3 1773
深忆病人
深忆病人 2020-12-15 10:03

I have a NSMutableDictionary with string keys and every key has its own array. I want to re-sort the dictionary with keys value alphabetically. How can I do thi

3条回答
  •  难免孤独
    2020-12-15 10:24

    NSDictionary *yourDictionary;
    NSArray *sortedKeys = [yourDictionary.allKeys sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"self" ascending:YES]]];
    NSArray *sortedValues = [yourDictionary objectsForKeys:sortedKeys notFoundMarker:@""];
    

提交回复
热议问题