0

我有一个带有数据的 NSMutableArray:

Name ... Male ... Age ... Point
("David"..."Male"...18...7.25)
("Mary"..."Female"...16...20.50)
("Kend"..."Male"...17...4.50)
("Frank"..."Male"...25...27.50)
("Cain"..."Female"...28...2.25)
("Sims"..."Female"...17...10.50)

...

我想按关键点对这个 NSMutableArray 进行排序。我试过了:

NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Point" ascending:NO];
[self.arrayPupils sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];

和输出:

David/Male/18/7.25
Kend/Male/17/4.50
Frank/Male/25/27.50
Mary/Female/16/20.50
Cain/Female/28/2.25
Sims/Female/17/10.50

但预期的结果是:

Frank/Male/25/27.50
Mary/Female/16/20.50
Sims/Female/17/10.50
David/Male/18/7.25
Kend/Male/17/4.50
Cain/Female/28/2.25

请帮助我...非常感谢。

4

1 回答 1

0

您的排序是按年龄排序。您需要改为按“点”排序以获得该输出。

于 2013-01-07T07:23:17.103 回答