Sort by Double Value and not String Value <p>I'm currently pulling info from an sql DB where the 'cachedDist' column is set as a double. However when I pull it into my app and create my array I turn it into an String and the sort will obviously be off, 18.15 will come before 2.15. How do I fix that in my code so it will sort distance as a Double and not a String?</p> <p>In Bar object.</p> <pre><code>NSString *cachedDist @property(nonatomic,copy) NSString *cachedDist; </code></pre> <hr> <pre><code>@synthesize cachedDist; </code></pre> <hr> <p>My while loop in the View Controller.</p> <pre><code>while (sqlite3_step(sqlStatement)==SQLITE_ROW) { Bar * bar = [[Bar alloc] init]; bar.barName = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,1)]; bar.barAddress = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,2)]; bar.barCity = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 3)]; bar.barState = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 4)]; bar.barZip = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 5)]; bar.barLat = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 8)]; bar.barLong = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement, 9)]; if (currentLoc == nil) { NSLog(@"current location is nil %@", currentLoc); }else{ CLLocation *barLocation = [[CLLocation alloc] initWithLatitude:[bar.barLat doubleValue] longitude:[bar.barLong doubleValue]]; bar.cachedDist = [NSNumber numberWithDouble:[currentLoc distanceFromLocation: barLocation]/1000]; [thebars addObject:bar]; } </code></pre> <p>My sorting</p> <pre><code>NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"cachedDist" ascending:YES]; sortedArray = [thebars sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]]; return sortedArray; </code></pre>