I am geting stuck here
I have array of latitude and longitude here , Get it from JSON Parsing
Arr_Lat=[[[[main valueForKey:@"responseData"]valueForKey:@"results"]valueForKey:@"lat"] copy];
Arr_Long=[[[[main valueForKey:@"responseData"]valueForKey:@"results"]valueForKey:@"lng"] copy];
I had calculate the distance between Current Location And array of lat and long index wise and store in to a Array……
CLLocation *currLoc = [[CLLocation alloc] initWithLatitude:appDel.curr_lat longitude:appDel.curr_long];
CLLocation *destLoc = [[CLLocation alloc] initWithLatitude:appDel.str_lat longitude:appDel.str_long];
distance = [destLoc distanceFromLocation:currLoc]/1000;
DistStr = [[NSMutableString alloc]initWithFormat:@" %0.3f",distance];
[appDel.Arr_distance addObject:DistStr];
I had sort the distance like this
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES]autorelease];
sortedFloats = [appDel.Arr_distance sortedArrayUsingDescriptors:
[NSArray arrayWithObject:sortDescriptor]];
I had display the title,address and distance but address and distance are not MATCH
I want to sort address according to ascending distance array….
Thanks For Help in Advance……………..
Arr_distance is NSString and I think it’s not correct to sort an array like that.
Try this:
You may need to exchange the NSOrderedDescending or NSOrderedAscending as you need.