Created
June 10, 2018 21:11
-
-
Save joshbarrass/813709a6ef0c4b7fb220a3e02c46214d to your computer and use it in GitHub Desktop.
One-line merge sort in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
olmerge = lambda l:l if len(l)==1 else (lambda l1,l2: ( lambda half,l1,l2: half+l1 if not len(l2) else half+l2 if not len(l1) else half+l1+l2 )([[l1.pop,l2.pop][l1[0]>l2[0]](0) for x in range([len(l1),len(l2)][len(l1)>len(l2)]*2) if (len(l1)>0 and len(l2)>0)],l1,l2) )(olmerge(l[:len(l)//2]),olmerge(l[len(l)//2:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment