I've an array from core data and I'm trying to think how can I sort the array by the nearest distance:
for (int i=0; i<allTasks.count; i++) {
        id singleTask = allTasks[i];
        double latitude = [singleTask[@"latitude"] doubleValue];
        double longitude = [singleTask[@"longitude"] doubleValue];
    }
EDIT: The distance between current location and all the locations in the array. I know how to calculate the distance, I don't know how to sort them.
 
     
     
     
     
     
    