html的for循环嵌套实现排序

来源:互联网 发布:淘宝店铺怎么来搞信誉 编辑:程序博客网 时间:2024/04/30 11:38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>for循环嵌套实现排序</title>l</head><body><script language="javascript"><!--// 定义变量引用一个数组对象var oMyArray = new Array( 13, 55, 37, 33, 45, 9, 60, 21, 10 );// 输出排序前的数组document.write( "排序前:" + oMyArray );// 开始排序for ( index in oMyArray ){    for ( i in oMyArray )    {        if( oMyArray[index]>oMyArray[i] )        {            nTemp = oMyArray[index];            oMyArray[index] = oMyArray[i];            oMyArray[i] = nTemp;        }    } }// 输出排序后的数组document.write( "<br>排序后:" + oMyArray );--></script></body></html>

1 0
原创粉丝点击