帮忙看一下该代码
<script language="javascript"><!--
var simplearray= new Array(9,10,52,369,120);
document.write("一维数组排序:<br>");
document.write("排序前:"+simplearray.join()+"<br>");
simplearray.sort();
document.write("直接使用sort方法排序后:"+simplearray.join()+"<br>");
simplearray.sort(compare);
document.write("使用比较函数compare排序后:"+simplearray.join()+"<br>");
function compare(a,b){
return(a-b);
}
document.write("<p>");
document.write ("两列数组的排序:<br>");
var tableobj=new Array();
tableobj[0]=new Array("a","9");
tableobj[1]=new Array("c","1");
tableobj[2]=new Array("z","3");
tableobj[3]=new Array("c","0");
tableobj[4]=new Array("m","2");
function compare0(a,b){
if (a[0]>b[0]) return 1;
if (a[0]<b[0]) return -1;
return 0;
}
function compare1(a,b){
if (a[1]>b[1]) return 1;
if (a[1]<b[1]) return -1;
return 0;
}
function compare01(a,b){
if (a[0]+a[1]>b[0]+b[1]) return 1;
if (a[0]+a[1]<b[0]+b[1]) return -1;
return 0;
}
document.write("排序前:<br>");
displayitems()
document.write("<BR>按第一列排序:<BR>");
tableobj.sort(compare0);
displayitems();
document.write("<BR>按第二列排序:<BR>");
tableobj.sort(compare1);
displayitems();
document.write("<BR>按第一和第二列排序<BR>");
tableobj.sort(compare01);
displayitems();
function displayitems(){
for (item1 in tableobj){
for (item2 in tableobj[item1]){
document.write(tableobj[item1][item2]+" ");
}
document.write("<BR>");
}
}
//-->
</script>
请帮忙.上便中的两例红色字体是什么意思呢?小弟看不明白.谢谢