当前位置: 代码迷 >> ASP >> ASP文本加数字的排序请问
  详细解决方案

ASP文本加数字的排序请问

热度:68   发布时间:2012-04-19 14:36:43.0
ASP文本加数字的排序请教
我现在有如下一段字符串:
少锡:38,多锡:3,连锡:5,锡刺:0,锡渣:0,未焊:0
请问如下进行排序,转化成为:
少锡:38,连锡:5,多锡:3,锡刺:0,锡渣:0,未焊:0


------解决方案--------------------
VBScript code
dim str:str = "少锡:38,多锡:3,连锡:5,锡刺:0,锡渣:0,未焊:0"
dim arr:arr = split(str,",")
for i = 0 to ubound(arr)
    dim temp,iv,jv    
    for j = i to ubound(arr)
        iv = split(arr(i),":")(1)
        jv = split(arr(j),":")(1)
        if(int(iv) < int(jv)) then
            temp = arr(i)
            arr(i) = arr(j)
            arr(j) = temp
         end if
    next
next
Response.Write(join(arr,",")) 
  相关解决方案