Sorting Algorithms (bubble sort, merge sort)
What key feature of merge sort is demonstrated by this merge function?
function merge(left, right) {
const result = [];
let leftIndex = 0, rightIndex = 0;
while (leftIndex < left.length && rightIndex < right.length) {
if (left[leftIndex] <= right[rightIndex]) {
result.push(left[leftIndex++]);
} else {
result.push(right[rightIndex++]);
}
}
return result.concat(left.slice(leftIndex), right.slice(rightIndex));
}