Sorting an Array with Strings that contains Numbers
arrays, objective-c, xcode
Solution
You can use an `NSSortDescriptor` and pass `doubleValue` as the key.
//sfloats would be your [myDict allKeys]
NSArray *sfloats = @[ @"192.5235", @"235.4362", @"3.235", @"500.235", @"219.72" ];
NSArray *myArray = [sfloats sortedArrayUsingDescriptors:
@[[NSSortDescriptor sortDescriptorWithKey:@"doubleValue"
ascending:YES]]];
NSLog(@"Sorted: %@", myArray);
Problem
Possible Duplicate: Sorting NSString values as if NSInteger using NSSortDescriptor I have an Array that I fill with my NSMutableDictionary.. and I use this: ``` myArray =[[myDict allKeys]sortedArrayUsingSelector:@selector(IDONTKNOW:)]; ``` AllKeys of myDicts are NSStrings... like 123.423 or 423.343... I need to sort the new myArray by incremental numbers.. 12.234 45.3343 522.533 5432.66 etc etc What must insert in @selector to do this properly? Thanks