title: Apply void function on array
body: <p>I am learning swift right now and wanted to write a quicksort algorithm for [Int]</p>
  
  <pre><code>func swap(array:[Int], x:Int, y:Int)-&gt;[Int] {  //swap elements in array
      var result:[Int] = array
      result[y] = array[x]
      result[x] = array[y]
      return result
  }
  
  func split(array:[Int], u:Int, o:Int , p:Int)-&gt;Int {  //where the sorting happens
      let pivot:Int = array[p]
      swap(array: array, x: p, y: o)
      var pn:Int = u
  
      for j in u...o {
          if(array[j] &lt;= pivot) {
          swap(array: array, x: pn, y: j)
          pn = pn+1
          }
      }
      swap(array: array, x: pn, y: o);
      return pn;
  }
  
  func quickSortR(array:[Int],u:Int ,o:Int) {  //recursive call
      if(u &lt; o){
          let p:Int = o
          let pn:Int = split(array: array, u: u, o: o, p: p)
          quickSortR(array: array,u: u,o: pn-1)
          quickSortR(array: array,u: pn+1,o: o)
      }
  }
  
  func quickSort(array:[Int]) {  //initial call
      quickSortR(array: array, u: 0, o: array.count-1)
  }
  </code></pre>
  
  <p><strong>My problem is</strong> that I don't know how to apply this implementation on an array.</p>
  
  <p>For example if I got the array <code>a:[Int] = [3,1,2]</code>.
  I can't check if the implementation is working by <code>print(quickSort(a))</code>, because the return type of <code>quickSort</code> is <code>void</code>.
  Of course I can't apply <code>quickSort</code> on that array like <code>a.quickSort(a)</code></p>
  
  <p>I really don't want to change my implementation of the algorithm by much if it isn't the cause of that problem (e.g. just the signature or return type)</p>