I tried to do a mergesort function for an assignment without importing merge from heapq:def mergesort(a):    if len(a) < 2:        return a    return mymerge(mergesort(a[len(a) // 2:]), mergesort(a[:len(a) // 2]))def mymerge(list1, list2):    for i in range(len(list1)):        for x in range(len(list2)):            if list1[0] < list2[x]:                list2.insert(x, list1[0])                list1.pop(0)                break            if list1[0] > list2[len(list2) - 1]:                list2.append(list1[0])                list1.pop(0)                break    return list2Could this be considered a valid mergesort or does my function have flaws? Are there ways to improve the mymerge function?
Could this be considered a valid mergesort?
python;python 3.x;sorting;mergesort;heap