标签:[] java javascrip log splice meta class length push
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <script type="text/javascript"> var arr=[85, 24, 63, 45, 17, 31, 96, 50]; var quickSort = function(arr) { if (arr.length <= 1) { return arr; } var pivotIndex = Math.floor(arr.length / 2); var pivot = arr.splice(pivotIndex, 1)[0]; var left = []; var right = []; for (var i = 0; i < arr.length; i++){ if (arr[i] < pivot) { left.push(arr[i]); } else { right.push(arr[i]); } } return quickSort(left).concat([pivot], quickSort(right)); }; </script> </head> <body> </body> </html>
标签:[] java javascrip log splice meta class length push
原文地址:http://www.cnblogs.com/taoxiaodan/p/6155765.html