Skip to content

Instantly share code, notes, and snippets.

@antoniopicone
Created October 17, 2017 14:11
Show Gist options
  • Save antoniopicone/bfff9d19786647cf907fe991b9eca1ae to your computer and use it in GitHub Desktop.
Save antoniopicone/bfff9d19786647cf907fe991b9eca1ae to your computer and use it in GitHub Desktop.
// require Merge.js
var MergeSort = function(A,p,r) {
if (p < r) {
var q = Math.floor(r-p);
var left = MergeSort(A,p,q);
var right = MergeSort(A,q+1,r);
return Merge(A,p,q,r);
}
return A;
};
var ar=[null,6,7,8,9,1,2,3,4,5];
console.log(MergeSort(ar,1,9));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment