title: Can I compare number with string format directly in Swift?
body: <p>I found I can compare two numbers in String format directly in Swift.</p>
  
  <p>Initially, I was trying to cast my String format number to double or Int, and then do the comparison. When I accidentally found I can compare them directly, I have done some tests in my playground. It seems the result are all correct, even with the numbers are empty string or "(Double)" vs "(Int)".<br>
  (Exceptions): The test cases with negative numbers in the String format will fail the comparing.</p>
  
  <p>Does anyone know if this is a default behavior in Swift String? I am not sure if I can utilize this in my program. </p>
  
  <p>Example:</p>
  
  <pre><code>var numStrs1 = ["15", "12.2", "15", ""]
  var numStrs2 = ["13", "12", "", "23.0"]
  
  func compareNumStr(numStr1:String, numStr2:String) -&gt; Bool {
      return numStr1 &gt; numStr2
  }
  
  for var i = 0; i &lt; numStrs1.count; ++i{
      compareNumStr(numStrs1[i], numStrs2[i])
  }
  </code></pre>