<script type="text/javascript">
var R1=[5,2,10,4,90,88,65,62];
var R2=[5,2,10,4,90,88,65,62];
function BubbleSort1(){
var n=R1.length;
for(var i=0;i<n-1;i++){
var flag=false;
for(var j=0;j<n-i;j++){
var temp;
if(R1[j]<R1[j+1]){
temp=R1[j+1];
R1[j+1]=R1[j];
R1[j]=temp;
}
flag=true;
}
if(!flag) return;
}
}
BubbleSort1();
document.write(R1.join(",")+"<br/>");
function BubbleSort2()
{
var n=R2.length;
for(var i=0;i<n-1;i++)
{
var flag=false;
for(var j=0;j<n-i;j++)
{
var temp;
if(R2[j]>R2[j+1])
{
temp=R2[j];
R2[j]=R2[j+1];
R2[j+1]=temp;
}
flag=true;
}
if(!flag) return;
}
}
BubbleSort2();
document.write(R2.join(","))
</script>