나는 친구 목록의 nsmutable 배열을 가지고 있습니다. 자신의 위도가 &입니다. 나는 그 배열을 autor에서 거리의 오름차순으로 정렬하고 싶습니다. 나는 autor와 친구들의 거리 값을 알아 냈습니다. `내가 그 일을하고 방법을 자신의 distances.This의 상승에 해당 배열을 정렬 할거리의 오름차순으로 NSmutable 배열을 정렬하는 방법은 무엇입니까?
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];
}
은`어떤 몸은 내가 거리의 ascecending 순서 내 배열을 정렬하는 데 도움이 수 있습니까?
CoreData에서이 배열을 가져오고 있습니까? –
아니 .... 서비스에서 반환? – hacker
당신의 주요 문제는 무엇입니까? CLLocationDistance 거리에서 모든 거리를 얻을 수 있습니다. 배열에 저장하십시오. 이것은 이중 값입니다. 너는 어떻게 두 배 가치를 분류하는 지 모른다? – CRDave