开发者

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]; }]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜