var arr=【1,'A',2,3,1,2,3,5,5,5,'b'】
如何变成 [5,5,5,1,1,2,2,3,3,'A','b']
要求: 1.进行数字,字母排序 2.出现次数多的字符排在前边
var arr=[1,'A',2,3,1,2,3,5,5,5,'b'] let a = arr.reduce((b,k)=>(b[k]++||(b[k]=1),b),{}) let result = [] let i for(i in a){ if(i>=0){result.unshift(...new Array(a[i]).fill(Number(i)))} else{result.push(...new Array(a[i]).fill(i))} } console.log(result)