我想要sort NSMutableArray,它的结构是这样的,
Object1:NSMutableDictionary
Affiliation = 2165;
CallLetters = abc;
Channel = "2.1";
ChannelLocation = "";
ChannelSchedules = (
);
DisplayName = abc;
DvbTriplets = (
);
FullName = "bc";
IconAvailable = 1;
Order = 1;
ParentNetworkId = 2;
ServiceType = Digital;
SourceAttributeTypes =
HD
SourceId = 11222;
SourceType = Broadcast;
TiVoSupported = 1;
Type = "24-Hours";Object2:NSMutableDictionary
Affiliation = 1209;
CallLetters = "xyz";
Chann?el = "4.1";
ChannelLocation = "";
ChannelSchedules = (
);
DisplayName = "xyz";
DvbTriplets = (
);
FullName = "xyz";
IconAvailable = 1;
Order = 2;
ParentNetworkId = 5;
ServiceType = Digital;
SourceAttributeTypes = HD
SourceId = 111
SourceType = Broadcast;
TiVoSupported = 1;
Type = "24-Hours";
VirtualChannelNumber = "4.1";... ..。。。./
该数组包含许多对象,而这些对象包含许多字典。我希望能够使用通道键“NSMutableDictionary”按升序排列上面的数组?
如何对数组进行排序?
发布于 2011-10-13 18:21:28
使用NSSortDescriptor就可以了
NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Channel" ascending:YES];
[yourarrayobject sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];
[aSortDescriptor release];发布于 2011-10-13 18:48:24
要对对象数组进行排序,请执行以下操作:
How to sort NSMutableArray using sortedArrayUsingDescriptors?
https://stackoverflow.com/questions/7752563
复制相似问题