Skip to content

Instantly share code, notes, and snippets.

@callblueday
Created September 14, 2013 08:08
Show Gist options
  • Save callblueday/6559848 to your computer and use it in GitHub Desktop.
Save callblueday/6559848 to your computer and use it in GitHub Desktop.
function cutRedundant(arr){
for(var i=0;i<arr.length;i++)
for(var j=i+1;j<arr.length;j++)
if(arr[i]===arr[j]){arr.splice(j,1);j--;}
return arr.sort(function(a,b){return a-b});
}
调用方法:
a=[1,2,2,3,4,5,5];
console.log(cutRedundant(a));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment