标签:
<!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>
标签:
原文地址:http://www.cnblogs.com/aicpcode/p/4278704.html