Merge Sort 🔥

Run Settings
LanguagePython
Language Version
Run Command
def mergeSort(arr): if len(arr) == 1: return arr left = mergeSort(arr[:len(arr)//2]) right = mergeSort(arr[len(arr)//2:]) return Merge(left,right) def Merge(l1,l2): i,j = 0,0 merge = [] while i<len(l1) and j<len(l2): if l1[i] <= l2[j]: merge.append(l1[i]) i+=1 elif l1[i] > l2[j]: merge.append(l2[j]) j+=1 if i < len(l1): merge += l1[i:] elif j < len(l2): merge += l2[j:] return merge print(mergeSort(list(map(int,input().split()))))
Editor Settings
Theme
Key bindings
Full width
Lines