Array and Prototype : ToString() and Rotate() and overridding Array.Sort()


Array.prototype.ToString = function(){
var str = "";
for(i=0;i < this.length;i++){
str += " "+this[i];
}
return str;
}
if( !Array.prototype.Rotate ){
Array.prototype.Rotate = function(){
var first = this[0];
for(i=0;i < this.length-1;i++){
this[i] = this[i+1];
}
this[this.length-1] = first;
}
}
Array.prototype.ascSort = Array.prototype.sort;
Array.prototype.sort = function(){
this.ascSort();
this.reverse();
}
var ar = new Array(1,2,3,4,5);
alert(ar.ToString());
ar.Rotate();
alert(ar.ToString());
ar.sort();
alert(ar.ToString());