我正在尝试对一系列价格从低到高进行排序。我让它工作,但不是我想要的方式。长话短说,分拣机将数字按如下顺序排列:100 10900 200 290
而不是像这样排序
100 200 290 10900
这是我正在使用的代码。
-(void)filterPriceLowHigh {
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"ListPrice"
ascending:YES] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray;
sortedArray = [app.vehiclesArrayToDisplay
sortedArrayUsingDescriptors:sortDescriptors];
[app.vehiclesArrayToDisplay removeAllObjects];
[app.vehiclesArrayToDisplay addObjectsFromArray:sortedArray];
}
有人可以告诉我我需要在这里做什么吗?提前致谢。