I am working on an iOS app and I have data stored in CoreData that I am loading into a UITableView. The data entities have an attribute called id
which is a string
The Swifty way:
var arr = ["A1", "A10", "A11", "A12", "A2", "A3"]
arr.sort {dropFirst($0).toInt() < dropFirst($1).toInt()}
So you could use that directly, or use it as the basis of the block for your comparator. If you insist on doing this in what is effectively Objective-C, you can use NSString compare:options:
where the options:
include NSNumericSearch
.