0

下面显示了我的数组内容,我想显示我的数组列表

"Ex works"
"FOB antwerp"
"Australia - Maersk",
"Brazil - Santos", 
"Chili - San Antonio",
"Colombia - Havana",
"Jordan - Aqaba",
"Kuwait - Shuwaikh"

那是在2索引之后

"Ex works"
"FOB antwerp"

现在显示是这样的,

"Australia - Maersk",
"Brazil - Santos", 
"Chili - San Antonio",
"Colombia - Havana",
"Ex works"
"FOB antwerp"
"Jordan - Aqaba",
"Kuwait - Shuwaikh"

我想按升序显示剩余内容。谁能帮我整理一下。请按需要做。

4

1 回答 1

1

创建两个数组。第一个将您想要的项目放在顶部,其余的放在第二个。使用 anNSSortDescriptor对第二个array.

NSSortDescriptor *ageDescriptor = [[NSSortDescriptor alloc] initWithKey:@"age" ascending:YES];
NSArray *sortDescriptors = @[ageDescriptor];
NSArray *sortedArray = [employeesArray sortedArrayUsingDescriptors:sortDescriptors];
于 2013-07-01T13:09:05.783 回答