标签:
function quick_sort(arr) { var arry1, arry2, mid; if (arr.length < 2) return arr; else if (arr.length == 2) if (arr[0] > arr[1]) return arr.reverse(); else return arr; else { arry1 = new Array(); arry2 = new Array(); mid = arr[0]; for (var i = 1; i < arr.length; i++) { if (arr[i] < mid) arry1.push(arr[i]); else arry2.push(arr[i]); } } return (quick_sort(arry1).concat(mid, quick_sort(arry2))); }
标签:
原文地址:http://www.cnblogs.com/BryanRecomment/p/5042488.html