//排序并获取index的顺序:4,7,2,9-->9,7,4,2-->4,2,1,3
Array.prototype.getIndex=function(){
var orderLength = this.length;
var temp,tp;
var c=[];
for(var l=0;l<orderLength;l++){
c[l]=l;
}
for(var u=0;u<orderLength;u++){
for (var v=0;v<orderLength-u-1;v++){
if(this[v]<this[v+1]){
temp=this[v];
this[v]=this[v+1];
this[v+1]=temp;
tp=c[v];
c[v]=c[v+1];
c[v+1]=tp;
}
}
}
return c;
}
时间: 2024-10-16 22:37:30