var arr = [22, 33, 1, 34, 67, 100, 5, 7, 1, 34, 101]; var newArr = arr.sort(function(a,b){return a - b;}).filter(function(cv,index,self){return self.indexOf(cv) === index}); console.log(newArr);//[1, 5, 7, 22, 33, 34, 67, 100, 101]
var arr = [22, 33, 1, 34, 67, 100, 5, 7, 1, 34, 101]; var newArr = arr.sort(function(a,b){return a - b;}).filter(function(cv,index,self){return self.indexOf(cv) === index}); console.log(newArr);//[1, 5, 7, 22, 33, 34, 67, 100, 101]