title: What is wrong with the following merge sort algorithm?
body: <p>As the question states, I'm having trouble finding where is the issue within the following algorithm. It is the aux function for mergesort, i.e. the one used for combining sorted arrays.</p>
  
  <pre><code>func Merge(toSort *[]int, p, q, r int) {
      arr := *toSort
      L := arr[p:q]
      R := arr[q:r+1]
      fmt.Println(L)
      fmt.Println(R)
      i := 0
      j := 0
  
      for index := p; index &lt;= r; index++ {
          if i &gt;= len(L) {
              arr[index] = R[j]
              j += 1
              continue
          } else if j &gt;= len(R) {
              arr[index] = L[i]
              i += 1
              continue
          }
  
          if L[i] &gt; R[j] {
              fmt.Println("right smaller")
              arr[index] = R[j]
              j += 1
              continue
          }
          if L[i] &lt;= R[j] {
              fmt.Println("left smaller")
              arr[index] = L[i]
              i += 1
              continue
          }
  
      }
  
  }
  </code></pre>
  
  <p>For <code>arr := []int{1,7,14,15,44,65,79,2,3,6,55,70}</code> it gives as output <code>[1 2 2 2 2 2 2 2 3 6 55 70]</code>.</p>
  
  <p><a href="http://play.golang.org/p/OlrDxdFpIs" rel="nofollow">Golang Play link</a></p>
  
  <p>The JavaScript equivalent for this function works as expected, but I don't know why it isn't working in <code>Go</code></p>
  
  <p>Thank you</p>