<script type="text/javascript">
var arr = [10,20,8,9,3,2,1,2,2,2,8];
alert( superSort( arr ) );
function superSort( arr1 ) {
var arrFin = [];
for( var i = 0;i<arr.length;i++ ) //去重
{
var onOff = true;
for( var j = 0;j<arrFin.length;j++ )
{
if( arr[i] === arrFin[j] )
{
onOff = false;
break;
}
}
if( onOff ) //新数组中不存在此元素
{
arrFin.push( arr[i] );
}
}
for( var i = 0;i<arrFin.length-1;i++ ) //排序
{
for( var j = i+1;j<arrFin.length;j++ )
{
if( arrFin[i]>arrFin[j] )
{
var temp = arrFin[i];
arrFin[i] = arrFin[j];
arrFin[j] = temp;
}
}
}
return arrFin;
}
</script>