我有一个 NSDictionary unsortedArray 的 NSArray 看起来像:
(
{symbol = "ABC"; price = "9.01";}
{symbol = "XYZ"; price = "3.45";}
...
(
这是排序代码:
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"price" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:descriptor];
NSArray *sortArray = [unsortedArray sortedArrayUsingDescriptors:sortedDescriptors];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"symbol" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:descriptor];
NSArray *sortArray = [unsortedArray sortedArrayUsingDescriptors:sortedDescriptors];
符号键的排序结果正常,但价格键未排序。有什么问题?价格在 NSString 中,但想对其进行排序
3.45
9.01
...
提前致谢。