javascript之sort排序 var arr = [1, 5, 10, 1, 2, 8, 2] arr.sort(function(a, b) { //正序 倒序return b - a return a - b }) console.log(arr);