按键按字母顺序排序NSMutableDictionary

时间:2014-04-11 03:17:43

标签: objective-c

如果我有NSMutableDictionary keys {B,A,D,C}values {custom obj1, custom obj2, custom obj3, custom obj4}

我希望这可以归类为

{A,B,C,D} -> {custom obj2, custom obj1, custom obj4, custom obj3}

1 个答案:

答案 0 :(得分:0)

您无法自行排序词典。但是,您可以获取密钥数组[dictionary allKeys]并对其进行排序。类似的东西:

NSMutableArray mutableKeys = [[dictionary allKeys] mutableCopy];
[mutableKeys desiredSortingMethod];