0
一鍵我有一個NSMutableArray的數據:排序NSMutableArray裏與float數據類型
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
幫我請...非常感謝。
看不到Age的值。我們來看看Point。他們通過 「字母」 排序:7.xx> 4.XX> 1x.xx 例: 9.25> 826.50> 82.50> 8.50> 7.50 > ... – dev4life68
@ dev4life68你的代碼是由「年齡排序「,而不是」POINT「 – 2013-01-07 07:39:01