我有一个包含子 NSDictionaries 的 NSDictionary,我想知道是否可以通过子字典的“名称”键的值按字母顺序对主字典进行排序。
NSDictionary *student1 = @{@"first_name" : @"Scott", @"last_name" : @"Smith"};
NSDictionary *student2 = @{@"first_name" : @"John", @"last_name" : @"Donalson"};
NSDictionary *student3 = @{@"first_name" : @"Mary", @"last_name" : @"Patricia"};
NSDictionary *student4 = @{@"first_name" : @"Zack", @"last_name" : @"Elliot"};
NSDictionary *students = @{"001": student1, "002": student2, "003": student3, "004": student4};
我希望能够创建一个仅包含键但根据子字典中某些键的值进行排序的数组或可变数组。像这样的东西:
姓氏数组
["002", "004", "003", "001"];
名字数组
["002", "003", "001", "004"];