冒泡排序:
var arr = [100, 3, 20, 200, 60, 888, 0] console.log(‘arr1===‘, arr) for (var i = 0; i < arr.length - 1; i++) { for (var j = 0; j < arr.length - 1 - i; j++) { if (arr[j] < arr[j + 1]) { var temp = arr[j] arr[j] = arr[j + 1] arr[j + 1] = temp } } } console.log(‘arr2====‘, arr)
参考:
https://github.com/wangjianuo/blog/issues/2
原文:https://www.cnblogs.com/wangjianuo/p/11037245.html