i try to implement merge sort algorythm using python but the code doesn't work well : <p>here merge function:</p>

<pre><code>def __merge__(arr, middle):

    L = arr[:middle]
    R = arr[middle:]

    L.append(math.inf)
    R.append(math.inf)

    i = 0
    j = 0
    for k in range(0, len(arr)):

        if(L[i] &lt;= R[j]):
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1

    return arr
</code></pre>

<p>and here mergesort function that call intself recursively:</p>

<pre><code>def __mergeSort__(listOfNumber):

if(len(listOfNumber) &lt;= 1):
    return listOfNumber

middle = int( len(listOfNumber) / 2 )

print('merge lit: ', listOfNumber[:middle])
__mergeSort__(listOfNumber[:middle])
print('merge lit: ', listOfNumber[middle:])
__mergeSort__(listOfNumber[middle:])
print(__merge__(listOfNumber, middle))
return __merge__(listOfNumber, middle)
</code></pre>

<p>when I give array like[6,5,4,3,2,1] as input i receve this: [3, 2, 1, 6, 5, 4]</p>
