juwuyu

Results 1 comments of juwuyu

> arr.toString().split(",").sort((a,b)=>{ return a-b}) 1. split()方法是把字符串分割成字符数组,所以最后的排序是根据字符串的编码来排序,输出的也是字符串数组 2. 这个方法也没有去重 set方法去重,flat方法扁平化,最后把对象转化成数组: ```javascript var arry =[1,25,15,[1,2,15,5],15,25,35,1]; var set =new Set(arry.flat(Infinity).sort((a,b)=>(a-b))); var arr= [...set]; : console.log(arr)// [1, 2, 5, 15, 25, 35] ```` 参考https://www.liaoxuefeng.com/wiki/001434446689867b27157e896e74d51a89c25cc8b43bdb3000/0014345007434430758e3ac6e1b44b1865178e7aff9082e000/