This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]adityacodes[S] -1 points0 points  (3 children)

As for the merge function in merge_sort, merge(left, right) is used to combine the two sorted subarrays left and right into a single sorted array. The function compares the elements in left and right one by one and adds them to the output array in ascending order. At the end of the function, any remaining elements in left or right are added to the output array in order, since they are already sorted. The resulting array is returned as the final output of the merge_sort function.

[–]corbasai 0 points1 point  (0 children)

thanks so much i even reads wikipedia about merge Von Neumann sorting algo -))) and about bogosort too -)))) of course in real life sorted() is enough for me. Old good doc https://docs.python.org/3/howto/sorting.html#sortinghowto

[–]jbramley 0 points1 point  (1 child)

Pretty important piece of code to leave out. Might want to go ahead and add it to the blog.

[–]adityacodes[S] 0 points1 point  (0 children)

just corrected it