Sorting data numerically from a plist dictionary in a UIPicker
I'm using the following code to sort the results in a UIPicker. The results are coming randomly because I am usi开发者_如何学运维ng a dictionary / plist to store the data.
NSArray *components = [self.dobRangesDict allKeys];
NSArray *sorted = [components sortedArrayUsingSelector: @selector(compare:)];
self.dates = sorted;
this sorts the data, but I'm looking to sort the data numerically. Any ideas how I might go about accomplishing this?
thanks for any help.
There are a couple of options here.
My personal choice is to use [components sortedArrayUsingComparator:^(NSString *a, NSString *b) { return [a compare:b options:NSNumericSearch]; }]
精彩评论