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
npm install allalgorithms
const allalgorithms = require('allalgorithms');
const arr = [77, 2, 10, -2, 1, 7];
console.log(allalgorithms.sorting.mergeSort(arr))
// -> [-2, 1, 2, 7, 10, 77]
Returns a sorted array
array
: Unsorted Array