function mergeSort(arr) {
for (let step = 1; step < len; step *= 2) {
for (let i = 0; i < len; i = i + 2 * step) {
Math.min(i + 2 * step, len)
function mergeArrays(arr, left, right, end) {
for (let j = left; j < end; j++) {
if ( n < right && ( m >= end || arr[n] < arr[m] )) {
currentSort.push(arr[n]);
currentSort.push(arr[m]);
currentSort.forEach(function(item, index) {
arr[left + index] = item;