<script language="JavaScript" type="text/JavaScript">
function points(id,x,y,up,down,left,right){
this.id=id
this.x=x
this.y=y
this.up=up
this.down=down
this.left=left
this.right=right
}
function compareX(a,b){
return a.x-b.x
}
function compareY(a,b){
return a.y-b.y
}
function compareID(a,b){
return a.id-b.id
}
var b=new Array()
b[0]=new points(0,12,122)
b[1]=new points(1,220,11)
b[2]=new points(2,120,76)
b[3]=new points(3,44,90)
b[4]=new points(4,22,12)
b[5]=new points(5,170,100)
b[6]=new points(6,55,75)
b[7]=new points(7,48,120)
b.sort(compareX)
for (var i=0;i<b.length;i++){
if (i==0){
b[i].left=b[i].id
b[i].right=b[i+1].id
}else{
if (i==b.length-1){
b[i].left=b[i-1].id
b[i].right=b[i].id
}else{
b[i].left=b[i-1].id
b[i].right=b[i+1].id
}
}
}
b.sort(compareY)
for (var i=0;i<b.length;i++){
if (i==0){
b[i].up=b[i].id
b[i].down=b[i+1].id
}else{
if (i==b.length-1){
b[i].up=b[i-1].id
b[i].down=b[i].id
}else{
b[i].up=b[i-1].id
b[i].down=b[i+1].id
}
}
}
b.sort(compareID)
for (var i=0;i<b.length;i++){
document.write ("ID:"+b[i].id+",&nbsp;&nbsp;横坐标:"+b[i].x+",&nbsp;&nbsp;纵坐标:"+b[i].y+",&nbsp;&nbsp;上边是:"+b[i].up+",&nbsp;&nbsp;下边是"+b[i].down+",&nbsp;&nbsp;左边是:"+b[i].left+",&nbsp;&nbsp;右边是"+b[i].right+";<br>")
}
</script>