我有一个名为detailTexts
的数组,其数据来自浮点数:
CLLocation *location = [[CLLocation alloc] initWithLatitude:dlog longitude:dlig];
**CLLocationDistance meters = [userLocation distanceFromLocation:location];**
**float detailFloat = meters * 1000;**
if (meters < 10000) {
NSLog(@"%@", detailText);
[tableData addObject:name];
**detailText = [NSString stringWithFormat:@"%f", detailFloat];**
**[detailTexts addObject:detailText];**
}
我如何对数组进行排序以获得最近的位置? (我知道它在mysql中:SORT BY ...)
Xcode 4.3(更新版本),Mac OS X Lion
答案 0 :(得分:2)
NSArray *sortedArray =
[detailTexts sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];