Javascript Array mergeSort(arr)
// merge sort//from w w w . j av a2 s. c o m var mergeSort = function(arr) { var left = arr.slice(0, Math.floor(arr.length / 2)); var right = arr.slice(Math.floor(arr.length / 2)); if (arr.length < 2) { return arr; } return mergeArrays(mergeSort(left), mergeSort(right)); }