function paixu(arr){ if(Object.prototype.toString.call(arr) == "[object Array]") arr.sort((a,b)=>a-b); return arr; } let arr= [1,2,4,3]; console.log(paixu(arr));