N个变量,对其进行从大到小排序,得出结果。 例如: 
A,B,C,D,E,F 5个变量。对其进行比较时,考虑相等情况, 
得出结果前三个字母组成字符串(例:ABC),并可供以后调用。因为急着用,希望可以把代码贴出来看看,谢谢了。

解决方案 »

  1.   


    <html>
    <title>index</title>
    <head>
    <script>  
    var arrStr = ['A','D','C','B','A','Z','F'];
    arrSort = arrStr.sort().toString();
    alert(arrSort.split(",")[0]+arrSort.split(",")[1]+arrSort.split(",")[2]);
    </script> </head>
    <body ></body>
    </html>
      

  2.   

    楼主是这样吧.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="zourinet">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <script language="JavaScript">
    /* <![CDATA[ */
        Array.prototype.swap = function(i, j)
        {
            var temp = this[i];
            this[i] = this[j];
            this[j] = temp;
        }
        Array.prototype.selectionSort = function()
        {
            for (var i = 0; i < this.length; ++i)
            {
                var index = i;
                for (var j = i + 1; j < this.length; ++j)
                {
                    if (this[j] < this[index]) index = j;
                }
                this.swap(i, index);
            }
        }
    var str = "A,C,B,E,D,F";
    var arr = str.split(",");
    arr.selectionSort();
    document.write(arr[0]+arr[1]+arr[2]);
    /* ]]> */
    </script>
    </HEAD><BODY>
    <form method="post" action="">
    <div></div>
    </form>
    </BODY>
    </HTML>
      

  3.   

    N个变量,对其进行从大到小排序,得出结果。  例如:  
    A,B,C,D,E,F 5个变量。对其进行比较时,考虑相等情况,  
    得出结果前三个字母组成字符串(例:ABC),并可供以后调用。 因为急着用,希望可以把代码贴出来看看,谢谢了。不好意思可能是我说得不是很清楚。
    我的意思是:
    例如:  
    A,B,C,D,E,F 5个变量。
    A=9, B=8 ,C =7 ,D = 6 , E= 5 , F= 4。对其进行比较时,考虑相等情况,  
    得出结果
    前三个字母组成字符串(例:ABC),并可供以后调用