title: NSSortDescriptor in Swift
body: <p>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 <code>id</code> which is a string that contains an <code>A</code> followed by a number (i.e. "A1" "A2" etc).</p>
  
  <p>When I use this code for sorting, I end up with the table being sorted lexicographically (i.e. "A1" "A10" "A11" "A12" "A2" "A3" etc)  </p>
  
  <pre><code>let sortDescriptor = NSSortDescriptor(key: "id", ascending: true)
  fetchRequest.sortDescriptors = [sortDescriptor]
  </code></pre>
  
  <p>What I really want is for it to be sorted numerically, as you might expect. How do I go about doing this? I know that a <code>NSComparator</code> can be added as an argument to <code>NSSortDescriptor</code> but I can't for the life of me get it figured out. Thanks in advance for any help!</p>