In computer science, merge sort is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output
pip install allalgorithms
from allalgorithms.sorting import merge_sort
arr = [77, 2, 10, -2, 1, 7]
print(merge_sort(arr))
# -> [-2, 1, 2, 7, 10, 77]
Returns a sorted array
array
: Unsorted Array