我正在尝试NSDictionary
按升序排序。我正在使用这段代码:
NSDictionary *valDict = self.mGetDataDict[key][rowKey];
for (NSString *valueKey in
[[valDict allKeys] sortedArrayUsingSelector:@selector(compare:)])
{
if ([valueKey isEqualToString:@"attr"])
{
dictRow = self.mGetDataDict[key][rowKey][valueKey];
}
else {
NSString *valKey = self.mGetDataDict[key][rowKey][valueKey];
[arrSeatsStatus addObject:valKey];
}
}
这是我得到的输出:
1 = off;
10 = off;
2 = on;
3 = on;
4 = on;
5 = on;
6 = on;
7 = on;
8 = on;
9 = on;
这是所需的输出:
1: "off",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "off"
所需的输出是来自 JSON 的实际值。