Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Merge Sort Algorithm in javascript

function mergeSortedAlgo(array) {
    if(array.length <= 1) return array;

    let midPoint = Math.floor(array.length / 2);
    let leftArray = mergeSortedAlgo(array.slice(0, midPoint));
    let rightArray = mergeSortedAlgo(array.slice(midPoint));

    return mergeSortedArray(leftArray, rightArray);
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #Merge #Sort #Algorithm #javascript
ADD COMMENT
Topic
Name
6+1 =