class Solution:

# @param A a list of integers

# @param m an integer, length of A

# @param B a list of integers

# @param n an integer, length of B

# @return nothing

def merge(self, A, m, B, n):

if m == 0:

for x in B:

A.append(x)

return

if n == 0:return

```
if A[0] > B[n - 1]:
for i in range(n):
A.insert(i, B[i])
elif A[m] < B[n - 1]:
for x in B:
A.append(x)
else:
part = 0
for i in range(n):
if A[m - 1] < B[i]:
part = i
break
for i in range(part):
begin = 0
for j in range(begin, m + i):
if B[i] <= A[j]:
A.insert(j, B[i])
begin = j + 1
for i in range(part, n):
A.append(B[i])
```