我试图对NSDictionary进行排序.
从Apple docs我看到你可以使用keysSortedByValueUsingSelector:
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:63],@"Mathematics",[NSNumber numberWithInt:72],@"English",[NSNumber numberWithInt:55],@"History",[NSNumber numberWithInt:49],@"Geography",nil]; NSArray *sortedKeysArray = [dict keysSortedByValueUsingSelector:@selector(compare:)];@H_404_5@这使:
// sortedKeysArray contains: Geography,History,Mathematics,English@H_404_5@但我想要:
// sortedKeysArray contains: English,Geography@H_404_5@我已经读过你可以使用compare:options:和NSStringCompareOptions来改变比较以便在另一个方向上进行比较.
但是我不明白你如何发送compare:options:在选择器中有一个选项.
我想做这样的事情:
NSArray *sortedKeysArray = [dict keysSortedByValueUsingSelector:@selector(compare:options:NSOrderDescending)];@H_404_5@我应该如何切换比较的顺序?
有关:
https://discussions.apple.com/thread/3411089?start=0&tstart=0