ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
冒泡排序法 ```js var array = [37, 63, 25, 74, 99, 18, 54, 260, 13, 1, 156]; for (var i = 0; i < array.length - 1; i++) { for (var j = 0; j < array.length - 1 - i; j++) { if (array[j] > array[j + 1]) { var tmp = array[j]; array[j] = array[j + 1]; array[j + 1] = tmp; } } } console.log(array) ``` sort排序法 ``` array.sort(function (a, b) { return a - b; }); console.log(array) ```