Sort mutable array containing dictionary

NSComparator compareDistances = ^(id string1, id string2)
NSNumber *number1 = [NSNumber numberWithFloat:[string1 floatValue]];
NSNumber *number2 = [NSNumber numberWithFloat:[string2 floatValue]];

return [number1 compare:number2];

// sort list and create nearest list
NSSortDescriptor *sortDescriptorNearest = [NSSortDescriptor sortDescriptorWithKey:@”petrolStation.pointCoordinates.distance” ascending:YES comparator:compareDistances];
_nearestList = (NSMutableArray *)[_gasStations sortedArrayUsingDescriptors:@[sortDescriptorNearest]];


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s