var a = [ "1", "1.1", "1.1.1", "1.1.2", "1.2", "1.3", "1.4", "1.5", "2", "2.1", "2.1.1", "2.1.2", "2.2", "2.11.2", "2.11.11", "10.2.1", "10.2.2", "10.2.11", "10.11.1", "11.1.1", "11.1.2" ] //默认字符串排序(按位从左到右比较的) alert(a.sort().join("\r\n")); //自定义排序方法(按大小排序) alert(a.sort(function(a,b){ return a.split(".")[0] - b.split(".")[0]; }).join("\r\n"));