码迷,mamicode.com
首页 > 编程语言 > 详细

javascript函数2——排序

时间:2015-02-07 14:24:50      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
<head>
    <title>javascript排序</title>
    <meta charset="UTF-8">
    <script type="text/javascript">
        //根据数字进行函数的排序
        function sortByNum(a,b){
            return a-b;
        }
        var as = [1,2,"11","33","12",190];
        //对于js而言,默认是按照字符串来实现排序的
        as.sort(sortByNum);
        alert(as);


    </script>
</head>
<body>

</body>
</html>

  

javascript函数2——排序

标签:

原文地址:http://www.cnblogs.com/aicpcode/p/4278704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!