title: Objective-C Version comparison
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5160216/comparing-version-numbers">Comparing version numbers</a><br>
    <a href="https://stackoverflow.com/questions/12308659/how-to-use-compare-on-a-version-number-where-theres-less-parts-in-one-number-in">How to use compare on a version number where theres less parts in one number in Objective-C?</a>  </p>
  </blockquote>
  
  
  
  <p>I am attempting to sort an <code>NSMutableArray</code> of custom objects based on a property called <code>referenceID</code> which essentially resembles a version number.</p>
  
  <p>It seems that treating <code>referenceID</code> as an <code>NSNumber</code> and sorting it using <code>compareTo:</code> almost gets it right, but where it breaks is cases such as:</p>
  
  <pre><code>Result:           Should Be:
  1.1.1             1.1.1
  1.1.10            1.1.2
  1.1.2             ...
  ...               1.1.9
  1.1.9             1.1.10
  
  (Where ... is 1.1.2 through 1.1.9)
  </code></pre>
  
  <p>Are there any built in functions that will sort this properly? Or should I get started writing the sorting algorithm?</p>