title: Sort arrays to make odds before evens
body: <p>Given an array and then sort it to make the odds appearance before evens.
  So I wrote the method like below in Swift. I can't see anything wrong in this methods, but the logic is just not right.
  Anybody could give me a clue will save my life.
  Thanks in advance!</p>
  
  <p>Here's the code:</p>
  
  <pre><code>class OddsBeforeEvens {
      func sortArrayOddsBeforeEvens(var array: [Int]) -&gt; [Int]? {
          if array.isEmpty { return nil }
          let length = array.count
          var begin = 0
          var end = length - 1
          var temp: Int
          while (begin &lt; end) {
              while (begin &lt; end &amp;&amp; array[begin] / 2 != 0) {
                  begin += 1
              }
              while (begin &lt; end &amp;&amp; array[end] / 2 == 0) {
                  end -= 1
              }
              if (begin &lt; end) {
                  temp = array[begin]
                  array[begin] = array[end]
                  array[end] = temp
              }
          }
  
          return array
      }
  }   
  </code></pre>