sort NSDictionary values by key alphabetical order

后端 未结 4 1911
谎友^
谎友^ 2020-12-14 01:51

I can get an array of dictionary keys sorted by values, but how to I get an array of values sorted by dictionary keys? I\'ve been looking everywhere with no luck. Any help a

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 02:25

    My experience shows that sorting NSDictionary by keys is not much useful. Although after logging the NSDictionary they seem to be sorted, when needed to put them in a tableview they are not in order any more.

    I suggest storing the keys in an NSArray property and then query the NSDictionary objects according to the order of the keys in the NSArray.

提交回复
热议问题