排序搞砸了

时间:2015-07-25 06:41:59

标签: cocoa nsmutablearray nssortdescriptor

我已经在这段代码的帮助下实现了排序。我正面临一个问题。当排序发生时,数字9出现在15000之前。我不知道该怎么做。请帮忙!

NSSortDescriptor *lastDescriptor =
            [[NSSortDescriptor alloc]
             initWithKey:@"priceAmount"
             ascending:NO];
id obj;
NSEnumerator * enumerator = [self.messageStore objectEnumerator];
while ((obj = [enumerator nextObject]))
    DebugLog(@"%@", obj);
NSMutableArray *descriptors = [NSMutableArray arrayWithObject:lastDescriptor];
self.messageStore = (NSMutableArray *)[self.messageStore sortedArrayUsingDescriptors:descriptors];

1 个答案:

答案 0 :(得分:1)

使用选择器localizedStandardCompare

进行尝试
NSSortDescriptor *lastDescriptor = [[NSSortDescriptor alloc] initWithKey:@"priceAmount" ascending:NO selector:@selector(localizedStandardCompare:)];