我有一个 nsmutable 朋友列表数组。每个人都有他们的 lat&longs。我想用他们与 autor 的距离的升序对该数组进行排序。我发现了与 autor 的朋友的距离值,现在我想对它进行排序排列在他们距离的上升中。这就是我这样做的方式,`
for(int i=0;i<[searchfriendarray count];i++)
{
NSDictionary *payload =[searchfriendarray objectAtIndex:i];
NSLog(@"%@",payload);
NSString *memberid = [payload objectForKey:@"userID"];
CLLocation *locationofauthor;
CLLocation *locationoffriends;
if([memberid isEqualToString:uidstr])
{
NSString *latofauthor = [payload objectForKey:@"latitude"];
NSString *longofauthor=[payload objectForKey:@"longitude"];
double latofauthordouble = [latofauthor doubleValue];
double longofauthordouble=[longofauthor doubleValue];;
locationofauthor = [[CLLocation alloc] initWithLatitude:latofauthordouble longitude:longofauthordouble];
}
else
{
NSString *latoffriends = [payload objectForKey:@"latitude"];
NSString *longoffriends=[payload objectForKey:@"longitude"];
double latoffriendsdouble = [latoffriends doubleValue];
double longoffriendsdouble=[longoffriends doubleValue];;
locationoffriends = [[CLLocation alloc] initWithLatitude:latoffriendsdouble longitude:longoffriendsdouble];
}
CLLocationDistance distance = [locationofauthor distanceFromLocation:locationoffriends];
}
`任何人都可以帮助我按照距离的升序对数组进行排序吗?