问题点:
var line = ”AB045,AB047,AS087,AL0515,“ 根据*后面的数字大小,降序排序
代码:
先把最后的标点去掉,再根据“,”分隔成数组。
line=line.substr(0,line.length-1)
line=line.split(",")
var compare=function(x,y){
if(parseInt(x.substr(6))<parseInt(y.substr(6))){
return 1
}else if(parseInt(x.substr(6))>parseInt(y.substr(6))){
return -1
}else{
return 0
}
}
line=line.sort(compare)
一个比较详细的排序讲解(https://www.cnblogs.com/bbc66/p/9709219.html)